import { BaseCommand, flags } from '@adonisjs/core/ace' import { CommandOptions } from '@adonisjs/core/types/ace' import NntpService from '#services/NntpService' import QueueService from '#services/QueueService' import DeferredService from '#services/DeferredService' /** * Sends recorded deferred ranges (fully obfuscated ngPost articles, CONCEPT.md * D28) to the body queue, oldest first. Every article in them is downloaded: * their headers can't be grouped into files. */ export default class DeferredExpandRanges extends BaseCommand { public static commandName = 'deferred:expand-ranges' public static description = 'Queues the bodies of deferred article ranges (costly: every article is downloaded).' public static options: CommandOptions = { startApp: true, } @flags.number({ description: 'Ranges to expand', default: 10 }) declare limit: number public async run() { try { const { ranges, articles } = await DeferredService.expandRanges(this.limit) this.logger.info(`Expanded ${ranges} ranges: ${articles} articles sent to the body queue.`) } finally { await NntpService.shutdown() await QueueService.closeAll() } } }