import { BaseCommand, flags } from '@adonisjs/core/ace' import type { CommandOptions } from '@adonisjs/core/types/ace' import Planner from '#services/planner' /** * Merges adjacent planned tail ranges (Planner.mergeTail): the tail planner added a sliver a group every round * while nothing leased the tail; now it grows the group's open range instead, and this packs what is there. */ export default class RangesMergeTail extends BaseCommand { static commandName = 'ranges:merge-tail' static description = 'Merges adjacent planned tail ranges into ranges of RANGE_ARTICLES' static options: CommandOptions = { startApp: true } @flags.boolean({ description: 'Only count what would be merged' }) declare dryRun: boolean async run() { const { candidates, merged, dropped } = await Planner.mergeTail(this.dryRun) this.logger.info( `${candidates} planned tail ranges: ${dropped} ${this.dryRun ? 'would merge' : 'merged'} into ${merged} grown ranges (${candidates - dropped} left).` ) } }