use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use crate::domain::entity_type::EntityType; use crate::domain::ids::{BagId, GearId, TimelineEventId}; use crate::domain::listing::{SortDirection, SortKey}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct TimelineEventDetail { pub label: String, pub value: String, } /// Raw brew data for repeating a brew from the timeline. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct TimelineBrewData { pub bag_id: BagId, pub grinder_id: GearId, pub brewer_id: GearId, pub filter_paper_id: Option, pub coffee_weight: f64, pub grind_setting: f64, pub water_volume: i32, pub water_temp: f64, pub brew_time: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct TimelineEvent { pub id: TimelineEventId, pub entity_type: EntityType, pub entity_id: i64, pub action: String, pub occurred_at: DateTime, pub title: String, pub details: Vec, pub tasting_notes: Vec, pub slug: Option, pub roaster_slug: Option, pub brew_data: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct NewTimelineEvent { pub entity_type: EntityType, pub entity_id: i64, pub action: String, pub occurred_at: DateTime, pub title: String, pub details: Vec, pub tasting_notes: Vec, pub slug: Option, pub roaster_slug: Option, pub brew_data: Option, } #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum TimelineSortKey { OccurredAt, } impl SortKey for TimelineSortKey { fn default() -> Self { TimelineSortKey::OccurredAt } fn from_query(value: &str) -> Option { match value { "occurred-at" => Some(TimelineSortKey::OccurredAt), _ => None, } } fn query_value(self) -> &'static str { match self { TimelineSortKey::OccurredAt => "occurred-at", } } fn default_direction(self) -> SortDirection { match self { TimelineSortKey::OccurredAt => SortDirection::Desc, } } }