From e4b7f4586ca0e9b86464cdbb5d363ab964fcefb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 12 Sep 2026 08:58:57 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20fix:=20un-splice=20Even?= =?UTF-8?q?tAudience=20struct=20from=20EventAudienceKind::as=5Fstr=20match?= =?UTF-8?q?=20(L10=20merge=20defect)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/event.rs | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) 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(_)) )); }