import { BaseCommand, args, flags } from '@adonisjs/core/ace' import { CommandOptions } from '@adonisjs/core/types/ace' import NntpService from '#services/NntpService' import SeedOrchestrator from '#services/SeedOrchestrator' /** * Plans seed ranges (CONCEPT.md D38) for groups, from below what live * indexing, the backfill and earlier plans cover down to `--days` back (or * the server's oldest article). A group's backfill stops where its plan * starts. Ranges are interleaved across groups, newest first. * * node ace seed:plan alt.binaries.ath alt.binaries.mom --days 365 */ export default class SeedPlan extends BaseCommand { public static commandName = 'seed:plan' public static description = 'Plans article ranges of groups for seeding nodes to lease.' public static options: CommandOptions = { startApp: true, } @args.spread({ description: 'Groups' }) declare groups: string[] @flags.number({ description: 'How many days back (default: everything the server has)' }) declare days?: number @flags.number({ description: 'Articles per range', default: 2_000_000 }) declare size: number public async run() { try { const summary = await SeedOrchestrator.plan(this.groups, { days: this.days, size: this.size }) for (const s of summary) { this.logger.info(`${s.group}: ${s.ranges.toLocaleString('en')} ranges, articles ${s.from.toLocaleString('en')}–${s.to.toLocaleString('en')}.`) } } finally { await NntpService.shutdown() } } }