forge
Explore
Log in

Don't you dare go Hollow

Un-splice EventAudience struct from EventAudienceKind::as_str match (L10 merge defect)

Browse files at this commit

e4b7f4586ca0e9b86464cdbb5d363ab964fcefb6Ahmet Kaan GümüşParent: 3de84b7
  • fix
    • un-splice EventAudience struct from EventAudienceKind::as_str match (L10 merge defect)
Show full message
🗃️ fix: un-splice EventAudience struct from EventAudienceKind::as_str match (L10 merge defect)
src/domain/event.rsmodified+2 -28
@@ -1,4 +1,3 @@
1-use uuid::Uuid;
2 use crate::constant::{MAX_EVENT_DESCRIPTION_LEN, MAX_EVENT_TITLE_LEN};1 use crate::constant::{MAX_EVENT_DESCRIPTION_LEN, MAX_EVENT_TITLE_LEN};
3 use crate::domain::class_group::ClassGroupId;2 use crate::domain::class_group::ClassGroupId;
4 use crate::domain::course::CourseId;3 use crate::domain::course::CourseId;
@@ -8,6 +7,7 @@ use crate::domain::timestamp::Timestamp;
8 use crate::domain::user::UserId;7 use crate::domain::user::UserId;
9 use crate::error::{AppError, ValidationError};8 use crate::error::{AppError, ValidationError};
10 use crate::validate::{validate_optional, validate_required};9 use crate::validate::{validate_optional, validate_required};
10+use uuid::Uuid;
11 11
12 #[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)]12 #[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)]
13 #[sqlx(transparent)]13 #[sqlx(transparent)]
@@ -134,31 +134,6 @@ impl EventAudienceKind {
134 EventAudienceKind::School => "school",134 EventAudienceKind::School => "school",
135 EventAudienceKind::Role => "role",135 EventAudienceKind::Role => "role",
136 136
137-/// The five audience columns as one value — the write-side bundle. The row
138-/// keeps them flat; every write spells them as a unit, so a kind and its
139-/// payload always land together and only the payload matching `kind` is
140-/// ever non-NULL.
141-#[derive(Debug, Clone, PartialEq, Eq)]
142-pub struct EventAudience {
143- pub kind: EventAudienceKind,
144- pub role: Option<Role>,
145- pub course: Option<CourseId>,
146- pub class: Option<ClassGroupId>,
147- pub capacity: Option<i64>,
148-}
149-
150-impl EventAudience {
151- /// The audience of a row read back from the store.
152- pub fn of_row(event: &Event) -> Self {
153- Self {
154- kind: event.get_audience_kind(),
155- role: event.get_audience_role(),
156- course: event.get_audience_course().copied(),
157- class: event.get_audience_class().copied(),
158- capacity: event.get_audience_capacity(),
159- }
160- }
161-}
162 EventAudienceKind::Course => "course",137 EventAudienceKind::Course => "course",
163 EventAudienceKind::Class => "class",138 EventAudienceKind::Class => "class",
164 EventAudienceKind::Registration => "registration",139 EventAudienceKind::Registration => "registration",
@@ -345,8 +320,7 @@ mod tests {
345 Err(AppError::Conflict(_))320 Err(AppError::Conflict(_))
346 ));321 ));
347 assert!(matches!(322 assert!(matches!(
348- event_with(EventAudienceKind::Registration, None, None, past)323+ event_with(EventAudienceKind::Registration, None, None, past).registration_capacity(),
349- .registration_capacity(),
350 Err(AppError::Conflict(_))324 Err(AppError::Conflict(_))
351 ));325 ));
352 }326 }