feat: add find_last_slot_per_block method to schedule repositories and update related logic
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
//! These traits define the interface for data persistence.
|
||||
//! Implementations live in the infra layer.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use chrono::DateTime;
|
||||
use chrono::Utc;
|
||||
@@ -10,7 +12,7 @@ use uuid::Uuid;
|
||||
|
||||
use crate::entities::{Channel, GeneratedSchedule, PlaybackRecord, User};
|
||||
use crate::errors::DomainResult;
|
||||
use crate::value_objects::{ChannelId, UserId};
|
||||
use crate::value_objects::{BlockId, ChannelId, MediaItemId, UserId};
|
||||
|
||||
/// An in-app activity event stored in the database for the admin log view.
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -98,6 +100,13 @@ pub trait ScheduleRepository: Send + Sync {
|
||||
) -> DomainResult<Vec<PlaybackRecord>>;
|
||||
|
||||
async fn save_playback_record(&self, record: &PlaybackRecord) -> DomainResult<()>;
|
||||
|
||||
/// Return the most recent slot per block_id across ALL schedules for a channel.
|
||||
/// Resilient to any single generation having empty slots for a block.
|
||||
async fn find_last_slot_per_block(
|
||||
&self,
|
||||
channel_id: ChannelId,
|
||||
) -> DomainResult<HashMap<BlockId, MediaItemId>>;
|
||||
}
|
||||
|
||||
/// Repository port for activity log persistence.
|
||||
|
||||
Reference in New Issue
Block a user