| 7 | import { data } from '../api' |
| 8 | |
| 9 | export class CategoriesTable implements Table { |
| 10 | async create() { |
| 11 | const parser = new LogParser() |
| 12 | const logsStorage = new Storage(LOGS_DIR) |
| 13 | const generatorsLog = await logsStorage.load('generators.log') |
| 14 | |
| 15 | let items = new Collection<HTMLTableItem>() |
| 16 | parser |
| 17 | .parse(generatorsLog) |
| 18 | .filter((logItem: LogItem) => logItem.type === 'category') |
| 19 | .forEach((logItem: LogItem) => { |
| 20 | if (logItem.filepath.includes('undefined')) { |
| 21 | items.add([ |
| 22 | 'ZZ', |
| 23 | 'Undefined', |
| 24 | logItem.count.toString(), |
| 25 | `<code>https://iptv-org.github.io/iptv/${logItem.filepath}</code>` |
| 26 | ]) |
| 27 | |
| 28 | return |
| 29 | } |
| 30 | |
| 31 | const file = new File(logItem.filepath) |
| 32 | const categoryId = file.name() |
| 33 | const category: sdk.Models.Category | undefined = data.categoriesKeyById.get(categoryId) |
| 34 | |
| 35 | if (!category) return |
| 36 | |
| 37 | items.add([ |
| 38 | category.name, |
| 39 | category.name, |
| 40 | logItem.count.toString(), |
| 41 | `<code>https://iptv-org.github.io/iptv/${logItem.filepath}</code>` |
| 42 | ]) |
| 43 | }) |
| 44 | |
| 45 | items = items |
| 46 | .sortBy(item => item[0]) |
| 47 | .map(item => { |
| 48 | item.shift() |
| 49 | return item |
| 50 | }) |
| 51 | |
| 52 | const columns = new Collection<HTMLTableColumn>([ |
| 53 | { name: 'Category' }, |
| 54 | { name: 'Channels', align: 'right' }, |
| 55 | { name: 'Playlist', nowrap: true } |
| 56 | ]) |
| 57 | |
| 58 | const table = new HTMLTable(items, columns) |
| 59 | |
| 60 | const readmeStorage = new Storage(README_DIR) |
| 61 | await readmeStorage.save('_categories.md', table.toString()) |
| 62 | } |
| 63 | } |
nothing calls this directly
no outgoing calls
no test coverage detected