Trim the state database; Popular lists feeds the way Directory does

Drops the created columns on users, subscriptions and sessions, which were
written by every insert and read by nothing, and migrate()'s add list, whose
columns all predate 0.3.0. Removes Db::subscribed_feed_ids (no callers),
Db::subscriber_count (one caller wanting > 0) and Managed.orphaned (never
read). The old-database test now builds the tables with foreign keys on.

Popular now lists the feeds inside an OPML or a Patreon creator, never the
collection, as Directory does.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TAC7sLVqfKmY6rsTLXzNgk
This commit is contained in:
2026-09-12 13:15:55 +00:00
parent 457a58dcc5
commit a958f7cb37
10 changed files with 159 additions and 157 deletions

47
TODO.md
View File

@@ -1,30 +1,27 @@
# To do
## Cut what is no longer needed
## Trim the state database
From a whole-repo audit for over-engineering on 2026-09-12. Biggest cut first.
From an audit of the database layer and a read-only copy of production on 2026-09-12. The data
itself was clean: no leftover tables or indexes, 47 free pages, one stray `entry_state` row.
Check each against the code before cutting it.
- [x] **Pre-accounts adoption and the dead `entries` columns.** The copy of the old read state into
`entry_state` and the `entries.read`, `flagged` and `position` columns are gone. Its other half,
subscribing the first admin to the catalogue, was not dead and stays as `adopt_catalogue`.
(`src/db.rs`, `src/main.rs`)
- [x] **`contrib/` systemd units.** From before the container; nothing points at them.
- [x] **`migrate_opml_children`.** A one-time move of OPML children out of `config.toml` that has
run. Delete it and its call. (`src/main.rs`)
- [x] **The legacy `interval_mins` key.** Production uses `schedule`. Delete the field, the fallback
in `General::interval` and its test. (`src/config.rs`)
- [x] **`Db::entries` and `Db::count_entries`.** One-line wrappers only the tests call; the tests
call `entries_in` and `count_in` instead. (`src/db.rs`)
- [x] **`web::generate_token`.** Repeats `auth::new_session_token`. Use that. (`src/web.rs`)
- [x] **Page leftovers.** `globalEvery`, `S.busy`, `S.limit`, `unitOptions`' `firstLabel`, `--r`,
`.ep.open`, the phone `.ep .art`, the duplicate phone `.fhead.slim{flex-wrap}`, the second
`#sidebar{z-index}`, and the `on()` helper. (`web/index.html`)
- [x] **`logbuf` visitors.** `record_i64`, `record_u64` and `record_bool` repeat what `Visit`'s
defaults already do through `record_debug`. (`src/logbuf.rs`)
- [x] **The `infer` dependency.** Its torrent check is the `d8:announce` test on the next line.
- [x] **The `dirs` dependency.** `XDG_CONFIG_HOME`, `XDG_DATA_HOME` and `HOME` from `std::env`.
- [x] **The `tokio-stream` dependency.** `futures_util::stream::unfold` over the broadcast receiver.
- [x] **The icon inlined four times.** About 94 KB of base64 across both pages; serve it once as
`/icon.png` from `include_bytes!`, open without signing in like `/login`.
- [x] **`migrate()`'s add list.** All eight columns arrived in 0.2.0, and 0.5.0 only supports
upgrades from 0.3.0 on. Drop the list and its loop; keep the `retired` drop loop, which a
database coming from 0.4.0 still needs. (`src/db.rs`)
- [x] **`Db::subscribed_feed_ids`.** No callers; its doc says the scanner walks it, and it does not.
(`src/db.rs`)
- [x] **`Db::subscriber_count`.** One caller, which only asks whether it is above zero:
`subscriber_counts()?.contains_key(&id)`. (`src/db.rs`, `src/web.rs`)
- [x] **The `created` columns** on `users`, `subscriptions` and `sessions`. Written on every insert,
never read. Add them to `retired` and drop them from the inserts. (`src/db.rs`)
- [x] **`Managed.orphaned`.** Selected by `managed_feeds()` on every call and never read;
`FeedSummary.orphaned` is what the UI uses. (`src/db.rs`)
After these: `cargo test`, `node tests/page-smoke.js`, `npx playwright test`.
## Popular
- [x] **Popular lists feeds the way Directory does**: the feeds inside an OPML or a Patreon
creator, never the collection itself. (`src/web.rs`, `web/index.html`)
After these: `cargo test`, `node tests/page-smoke.js`, `npx playwright test`. Copy `state.db`
aside before deploying: `migrate()` drops columns on the first start.