Task #6127
closedCLI: companies-garbage-collect dispatches to UsersMetricsGatheringCommand
100%
Description
Found while reviewing the stats daemon (parent epic #6116).
Problem¶
Application.kt:131-133:
if (args.contains("companies-garbage-collect")) {
PicocliRunner.run(UsersMetricsGatheringCommand::class.java, …)
return
}
Copy-paste error — this runs the year-long IIKO user-metrics gather instead of the companies garbage collection. CompaniesGarbageCollectionCommand is reachable only via the obsolete-companies alias (line 151), which is what the daemon happens to use, so the bug is latent — but anyone invoking companies-garbage-collect by name triggers a very expensive unrelated job.
Also¶
UsersMetricsGatheringCommand is annotated @CommandLine.Command(name = "iiko-user-metrics-sync") while Application.kt dispatches on iiko-users-metrics-sync (plural) and scripts/workflow/download_users_stats.sh passes the plural form. The dispatch is a plain args.contains, so it works, but the picocli name and the invoked name should agree.
Fix¶
- Dispatch
companies-garbage-collecttoCompaniesGarbageCollectionCommand. - Align the picocli command name with the dispatched string.
- Consider replacing the chain of
args.containschecks with a real picocli subcommand registration, which would have made both mistakes impossible.
Updated by Redmine Admin about 9 hours ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Реализовано в ветке speedup/stats-daemon, коммит 50a6ebef.
-
companies-garbage-collectтеперь запускаетCompaniesGarbageCollectionCommand; -
UsersMetricsGatheringCommandпереименована в picocli вiiko-users-metrics-sync— совпадает с тем, что диспатчится вApplication.ktи что передаётdownload_users_stats.sh; - в
helpдобавлена новаяrun-stats-round.
Не сделано: цепочка args.contains(...) в Application.kt осталась как есть. Заменить её на нормальную регистрацию подкоманд picocli — правильно, и именно это не дало бы ошибке случиться, но это перетряхивает точку входа целиком и заслуживает отдельной задачи, а не довеска к ускорению демона.