diff --git a/k-tv-backend/domain/src/entities.rs b/k-tv-backend/domain/src/entities.rs index a1ecf5c..1a49b8d 100644 --- a/k-tv-backend/domain/src/entities.rs +++ b/k-tv-backend/domain/src/entities.rs @@ -348,7 +348,7 @@ pub struct MediaItem { pub episode_number: Option, } -/// A fully resolved 48-hour broadcast program for one channel. +/// A fully resolved 7-day broadcast program for one channel. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct GeneratedSchedule { pub id: Uuid, diff --git a/k-tv-backend/domain/src/services/schedule/mod.rs b/k-tv-backend/domain/src/services/schedule/mod.rs index ae69dc7..65e0857 100644 --- a/k-tv-backend/domain/src/services/schedule/mod.rs +++ b/k-tv-backend/domain/src/services/schedule/mod.rs @@ -20,7 +20,7 @@ mod recycle; /// Core scheduling engine. /// -/// Generates 48-hour broadcast schedules by walking through a channel's +/// Generates 7-day broadcast schedules by walking through a channel's /// `ScheduleConfig` day by day, resolving each `ProgrammingBlock` into concrete /// `ScheduledSlot`s via the `IMediaProvider`, and applying the `RecyclePolicy` /// to avoid replaying recently aired items. @@ -47,12 +47,12 @@ impl ScheduleEngineService { // Public API // ------------------------------------------------------------------------- - /// Generate and persist a 48-hour schedule for `channel_id` starting at `from`. + /// Generate and persist a 7-day schedule for `channel_id` starting at `from`. /// /// The algorithm: - /// 1. Walk each calendar day in the 48-hour window. + /// 1. Walk each calendar day in the 7-day window. /// 2. For each `ProgrammingBlock`, compute its UTC wall-clock interval for that day. - /// 3. Clip the interval to `[from, from + 48h)`. + /// 3. Clip the interval to `[from, from + 7d)`. /// 4. Resolve the block content via the media provider, applying the recycle policy. /// 5. For `Sequential` blocks, resume from where the previous generation left off /// (series continuity — see `fill::fill_sequential`). @@ -101,7 +101,7 @@ impl ScheduleEngineService { .await?; let valid_from = from; - let valid_until = from + Duration::hours(48); + let valid_until = from + Duration::days(7); let start_date = from.with_timezone(&tz).date_naive(); let end_date = valid_until.with_timezone(&tz).date_naive(); @@ -110,7 +110,8 @@ impl ScheduleEngineService { let mut current_date = start_date; while current_date <= end_date { - for block in channel.schedule_config.blocks_for(chrono::Weekday::from(current_date.weekday()).into()) { + let weekday = crate::value_objects::Weekday::from(current_date.weekday()); + for block in channel.schedule_config.blocks_for(weekday) { let naive_start = current_date.and_time(block.start_time); // `earliest()` handles DST gaps — if the local time doesn't exist @@ -123,7 +124,7 @@ impl ScheduleEngineService { let block_end_utc = block_start_utc + Duration::minutes(block.duration_mins as i64); - // Clip to the 48-hour window. + // Clip to the 7-day window. let slot_start = block_start_utc.max(valid_from); let slot_end = block_end_utc.min(valid_until);