Skip to content

Commit

Permalink
Fix plugevents importer for JSON format changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
qwandor committed Aug 6, 2024
1 parent 5a05d10 commit b57aef7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
25 changes: 19 additions & 6 deletions src/importers/plugevents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,25 @@ fn convert(event: &Event, style: DanceStyle) -> Result<Option<event::Event>, Rep
}
.to_string();

let (workshop, social) = match event.event_format {
EventFormat::Class => (true, false),
EventFormat::Fest => (true, true),
EventFormat::Meet => (false, true),
EventFormat::Party => (false, true),
};
let mut workshop = false;
let mut social = false;
for subinterest in &event.subinterests {
match subinterest {
EventFormat::Class => {
workshop = true;
}
EventFormat::Festival => {
workshop = true;
social = true;
}
EventFormat::Meeting => {
social = true;
}
EventFormat::Party => {
social = true;
}
}
}

Ok(Some(event::Event {
name: event.name.clone(),
Expand Down
8 changes: 3 additions & 5 deletions src/importers/plugevents/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,15 @@ pub struct Event {
pub is_free: bool,
pub price_display: Option<String>,
pub is_expanded: bool,
pub event_format: EventFormat,
pub event_format_display: String,
pub date_grouping_label: String,
pub subinterests: Vec<EventFormat>,
}

#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "UPPERCASE")]
pub enum EventFormat {
#[default]
Class,
Fest,
Meet,
Festival,
Meeting,
Party,
}

0 comments on commit b57aef7

Please sign in to comment.