cleanup: strip comments, extract constants, DRY shared helpers across adapters + infra-wiring

- strip all comments except WHY workaround notes (3 remain)
- remove all #[allow(dead_code)]; fix via _prefix rename
- extract named constants: JWT time units, token types, default config values, jellyfin fallback bitrate
- DRY: move serialize_enum_as_string, content_type_str, parse_content_type, parse_genres_blob to adapter-common
- sqlite+postgres library.rs use shared helpers instead of local copies
- sqlite+postgres channel.rs use shared serialize_enum_as_string
- remove dead `let _ = ext` in scanner.rs
This commit is contained in:
2026-07-12 04:21:21 +02:00
parent eff14228af
commit 25b33b6a0e
38 changed files with 188 additions and 630 deletions

View File

@@ -1,5 +1,3 @@
//! SQLite adapter for schedule persistence (ScheduleCommand + ScheduleQuery).
use std::collections::HashMap;
use async_trait::async_trait;
@@ -22,8 +20,6 @@ impl SqliteScheduleRepository {
}
}
// -- Row types ---------------------------------------------------------------
#[derive(Debug, sqlx::FromRow)]
struct ScheduleRow {
id: String,
@@ -36,8 +32,7 @@ struct ScheduleRow {
#[derive(Debug, sqlx::FromRow)]
struct SlotRow {
id: String,
#[allow(dead_code)]
schedule_id: String,
_schedule_id: String,
start_at: String,
end_at: String,
item: String,
@@ -59,8 +54,6 @@ struct PlaybackRecordRow {
generation: i64,
}
// -- Mapping -----------------------------------------------------------------
fn map_slot_row(row: SlotRow) -> DomainResult<ScheduledSlot> {
let id = SlotId::from_uuid(parse_uuid(&row.id, "slot id")?);
let source_block_id = BlockId::from_uuid(parse_uuid(&row.source_block_id, "block id")?);
@@ -103,8 +96,6 @@ fn map_playback_row(row: PlaybackRecordRow) -> DomainResult<PlaybackRecord> {
))
}
// -- Internal helpers --------------------------------------------------------
impl SqliteScheduleRepository {
async fn fetch_slots(&self, schedule_id: &str) -> DomainResult<Vec<SlotRow>> {
sqlx::query_as(
@@ -118,8 +109,6 @@ impl SqliteScheduleRepository {
}
}
// -- Command -----------------------------------------------------------------
#[async_trait]
impl ScheduleCommand for SqliteScheduleRepository {
async fn save(&self, schedule: &GeneratedSchedule) -> DomainResult<()> {
@@ -142,7 +131,6 @@ impl ScheduleCommand for SqliteScheduleRepository {
.await
.map_err(map_sqlx_error)?;
// Delete-then-insert all slots
sqlx::query("DELETE FROM scheduled_slots WHERE schedule_id = ?")
.bind(schedule.id().value().to_string())
.execute(&self.pool)
@@ -216,8 +204,6 @@ impl ScheduleCommand for SqliteScheduleRepository {
}
}
// -- Query -------------------------------------------------------------------
#[async_trait]
impl ScheduleQuery for SqliteScheduleRepository {
async fn find_active(