diff --git a/src/domain/event.rs b/src/domain/event.rs index c0498cc..5adc698 100644 --- a/src/domain/event.rs +++ b/src/domain/event.rs @@ -1,4 +1,3 @@ -use uuid::Uuid; use crate::constant::{MAX_EVENT_DESCRIPTION_LEN, MAX_EVENT_TITLE_LEN}; use crate::domain::class_group::ClassGroupId; use crate::domain::course::CourseId; @@ -8,6 +7,7 @@ use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; use crate::validate::{validate_optional, validate_required}; +use uuid::Uuid; #[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)] #[sqlx(transparent)] @@ -134,31 +134,6 @@ impl EventAudienceKind { EventAudienceKind::School => "school", EventAudienceKind::Role => "role", -/// The five audience columns as one value — the write-side bundle. The row -/// keeps them flat; every write spells them as a unit, so a kind and its -/// payload always land together and only the payload matching `kind` is -/// ever non-NULL. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct EventAudience { - pub kind: EventAudienceKind, - pub role: Option, - pub course: Option, - pub class: Option, - pub capacity: Option, -} - -impl EventAudience { - /// The audience of a row read back from the store. - pub fn of_row(event: &Event) -> Self { - Self { - kind: event.get_audience_kind(), - role: event.get_audience_role(), - course: event.get_audience_course().copied(), - class: event.get_audience_class().copied(), - capacity: event.get_audience_capacity(), - } - } -} EventAudienceKind::Course => "course", EventAudienceKind::Class => "class", EventAudienceKind::Registration => "registration", @@ -345,8 +320,7 @@ mod tests { Err(AppError::Conflict(_)) )); assert!(matches!( - event_with(EventAudienceKind::Registration, None, None, past) - .registration_capacity(), + event_with(EventAudienceKind::Registration, None, None, past).registration_capacity(), Err(AppError::Conflict(_)) )); }