Skip to content

Commit

Permalink
fix(db): support Sprint Qualifying event
Browse files Browse the repository at this point in the history
  • Loading branch information
obviyus committed Mar 9, 2024
1 parent 231cc86 commit fe124c2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub enum EventType {
Qualifying = 5,
Sprint = 6,
Race = 7,
SprintQualifying = 8,
}

impl EventType {
Expand All @@ -18,6 +19,7 @@ impl EventType {
"practice 2" | "p2" | "fp2" => Some(EventType::FreePractice2),
"practice 3" | "p3" | "fp3" => Some(EventType::FreePractice3),
"qualifying" | "quali" | "q" => Some(EventType::Qualifying),
"sprint qualifying" | "sq" | "sprint_qualifying" => Some(EventType::SprintQualifying),
"sprint" | "s" => Some(EventType::Sprint),
"race" | "r" | "gp" => Some(EventType::Race),
_ => None,
Expand All @@ -28,7 +30,7 @@ impl EventType {
match self {
EventType::LiveryReveal => "",
EventType::FreePractice1 | EventType::FreePractice2 | EventType::FreePractice3 => "🏎️",
EventType::Qualifying => "⏱️",
EventType::Qualifying | EventType::SprintQualifying => "⏱️",
EventType::Sprint => "🏎",
EventType::Race => "🏁",
}
Expand All @@ -41,6 +43,7 @@ impl EventType {
EventType::FreePractice2 => "Practice 2",
EventType::FreePractice3 => "Practice 3",
EventType::Qualifying => "Qualifying",
EventType::SprintQualifying => "Sprint Qualifying",
EventType::Sprint => "Sprint",
EventType::Race => "Race",
}
Expand All @@ -55,6 +58,7 @@ impl EventType {
5 => EventType::Qualifying,
6 => EventType::Sprint,
7 => EventType::Race,
8 => EventType::SprintQualifying,
_ => panic!("Invalid event type"),
}
}
Expand All @@ -64,7 +68,7 @@ pub async fn is_event_delivered(
pool: &SqlitePool,
path: &str,
) -> Result<bool, Box<dyn std::error::Error>> {
let result = sqlx::query!("SELECT TRUE FROM results WHERE path = ?", path)
let result = sqlx::query!("SELECT true FROM results WHERE path = ?", path)
.fetch_optional(pool)
.await?;

Expand Down

0 comments on commit fe124c2

Please sign in to comment.