fix(server): fetch content variants in get_content and list_content (COD-375) - #2
Conversation
get_content() was hardcoding variants: vec![], discarding saved platform variants. Added fetch_variants_for() helper to query the content_variants table and deserialize rows into Vec<PlatformVariant>. Also added variant_count subquery to list_content() summaries. Test: test_get_content_returns_variants verifies round-trip for two platforms plus the no-variants edge case. Closes COD-375 Co-authored-by: Archon <archon@purelymail.com>
🤖 Automated Review Panel
Review Findings (glm-5.1)Verdict: Change achieves the core goal. Three issues raised:
Post-review action: Error handling in |
Auto-Merge Gate ApprovalConfidence: 0.92 RationaleThe diff directly fulfills the stated goal: Acceptance Criteria (all met)
Checks Observed (5/5 SUCCESS)
Scope Limits
Merge MethodSquash + delete branch. Approved by CodeFold Auto-Merge Gate (cron |
Summary
Fixes COD-375
SqliteStorage::get_content()was hardcodingvariants: vec![], so platform variants saved viaadd_variant()were never read back. This PR:get_content()— Addedfetch_variants_for()helper that queries thecontent_variantstable and deserializes rows intoVec<PlatformVariant>. Variants are ordered byformatted_at ASCfor deterministic retrieval.list_content()— Added a correlated subquery (COUNT(*)fromcontent_variants) and a newvariant_count: usizefield onContentSummaryso list views can show how many variants each content item has.Error handling — Parse failures on
metadataJSON orformatted_attimestamps now propagate asanyhow::Resulterrors with context, rather than being silently masked. Corrupt DB data surfaces as an error, not silently swallowed.Test
New test
test_get_content_returns_variants:get_content()returns both variants with correct platform, text, and metadataORDER BY formatted_at ASClist_content()reports correctvariant_countAll 6 tests pass.
cargo clippy --all-targets --all-features -- -D warningsclean.cargo fmt --checkclean.Review Notes
Platform::from_db_key()is infallible (returnsPlatform, notResult) — it always maps any string to either a known variant orOther(String). This is by design from PR fix(server): fix SQLite enum serialization causing failing test_schedule_lifecycle #1.ContentSummaryhas a single construction site (list_content()), updated in this diff.