31 lines
743 B
Rust
31 lines
743 B
Rust
use rusqlite::{Connection, params};
|
|
|
|
use crate::model::Match;
|
|
|
|
/// Returns whether the Match was new.
|
|
pub(super) fn insert_match(
|
|
db: &Connection,
|
|
puuid: &str,
|
|
m: &Match,
|
|
queue_id: u32,
|
|
raw: &str,
|
|
) -> rusqlite::Result<bool> {
|
|
let inserted = db.execute(
|
|
"INSERT OR IGNORE INTO matches
|
|
(puuid, match_id, queue_id, champion_id, champion_name, placement, win, started_at_ms, raw)
|
|
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)",
|
|
params![
|
|
puuid,
|
|
m.match_id,
|
|
queue_id,
|
|
m.champion_id,
|
|
m.champion_name,
|
|
m.placement,
|
|
m.win,
|
|
m.started_at_ms,
|
|
raw
|
|
],
|
|
)?;
|
|
Ok(inserted == 1)
|
|
}
|