Skip to content

Remove product code that nothing in tg calls #228

Open

Description

@neoromantic

Nothing in tg calls the code below. I grepped src/ on main at 649eef9, leaving out *.test.ts and *.test-utils.ts; scripts/ and bin/ don't call it either. The package ships only the tg bin, with no main or exports, so none of this is a public API. Knip (knip.json) checks files, dependencies and imports, not exports, so it doesn't report any of it.

Code File Tests that still use it
UsersCache.getAll src/db/users-cache.ts none
UsersCache.count src/db/users-cache.ts src/db/cache.test.ts, as a row count
The type argument of ChatsCache.count, and its countByTypeStmt. count() with no argument is used, by tg chats search src/db/chats-cache.ts none pass a type
MessagesCache.countByChatId src/db/messages-cache.ts src/commands/send/send-cache.test.ts, src/daemon/sync-worker-real-jobs.test.ts (assertions)
ChatSyncStateService.delete src/db/chat-sync-state.ts src/daemon/sync-worker-real-jobs.test.ts (setup of one test)
SyncJobsService.getNextPending. The scheduler uses getNextPendingOfTypes src/db/sync-jobs.ts src/daemon/sync-worker-real-jobs.test.ts
SyncJobsService.markFailed. The worker uses failOrDrop and retryLater src/db/sync-jobs.ts src/db/sync-jobs.test.ts, src/daemon/sync-scheduler.test.ts, src/test/chats-sync.e2e.test.ts (to make failed jobs)
accountsDb.updateSession src/db/index.ts none
accountsDb.count src/db/index.ts src/commands/auth.test.ts
Daemon.getStatus and Daemon.isRunning, with the DaemonStatus type that getStatus returns. tg daemon start calls only start() src/daemon/daemon.ts, src/daemon/types.ts none
totalMessagesSynced. Only Daemon.getStatus calls it src/daemon/daemon-context.ts none
stringifyTable src/utils/csv.ts none
CsvOptions (includeHeader, delimiter). tg sql --output csv calls stringify(rows, columns) with no options src/utils/csv.ts src/commands/sql.test.ts
vacuumCache throwing VacuumNeedsStoppedDaemonError, and the catch for it in tg db vacuum. Before calling vacuumCache (its only caller), the command checks the same condition (daemon running, auto_vacuum none) and exits with DAEMON_ALREADY_RUNNING, so neither runs src/db/cache-maintenance.ts, src/commands/db.ts none

Done when each item is gone, or has a caller in tg. Tests that used an item should read the table directly or use the code tg runs, and keep proving the same behaviour. For the vacuum refusal, keep one of the two checks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions