Files
k-tv/crates/domain/src/ports/schedule.rs
Gabriel Kaszewski 98a54245b1 domain crate code quality cleanup
strip all comments, extract tests to tests/ dirs,
remove #[allow(clippy::...)], extract magic numbers to
constants, refactor schedule engine private methods to
use param structs, add Default impls, clippy.toml for
persistence constructors
2026-07-12 04:02:12 +02:00

56 lines
1.5 KiB
Rust

use std::collections::HashMap;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use crate::errors::DomainResult;
use crate::models::{GeneratedSchedule, PlaybackRecord};
use crate::value_objects::{BlockId, ChannelId, MediaItemId, ScheduleId};
#[async_trait]
pub trait ScheduleCommand: Send + Sync {
async fn save(&self, schedule: &GeneratedSchedule) -> DomainResult<()>;
async fn save_playback_record(&self, record: &PlaybackRecord) -> DomainResult<()>;
async fn delete_schedules_after(
&self,
channel_id: ChannelId,
target_generation: u32,
) -> DomainResult<()>;
}
#[async_trait]
pub trait ScheduleQuery: Send + Sync {
async fn find_active(
&self,
channel_id: ChannelId,
at: DateTime<Utc>,
) -> DomainResult<Option<GeneratedSchedule>>;
async fn find_latest(
&self,
channel_id: ChannelId,
) -> DomainResult<Option<GeneratedSchedule>>;
async fn find_playback_history(
&self,
channel_id: ChannelId,
) -> DomainResult<Vec<PlaybackRecord>>;
async fn find_last_slot_per_block(
&self,
channel_id: ChannelId,
) -> DomainResult<HashMap<BlockId, MediaItemId>>;
async fn list_schedule_history(
&self,
channel_id: ChannelId,
) -> DomainResult<Vec<GeneratedSchedule>>;
async fn get_schedule_by_id(
&self,
channel_id: ChannelId,
schedule_id: ScheduleId,
) -> DomainResult<Option<GeneratedSchedule>>;
}