Project

General

Profile

Actions

Task #6127

closed

CLI: companies-garbage-collect dispatches to UsersMetricsGatheringCommand

Added by Redmine Admin about 9 hours ago. Updated about 9 hours ago.

Status:
Resolved
Priority:
High
Assignee:
-
Start date:
08/26/2026
Due date:
% Done:

100%

Estimated time:

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-collect to CompaniesGarbageCollectionCommand.
  • Align the picocli command name with the dispatched string.
  • Consider replacing the chain of args.contains checks with a real picocli subcommand registration, which would have made both mistakes impossible.
Actions #1

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 — правильно, и именно это не дало бы ошибке случиться, но это перетряхивает точку входа целиком и заслуживает отдельной задачи, а не довеска к ускорению демона.

Actions

Also available in: Atom PDF