fix: make fields that old files don't have optional
This commit is contained in:
parent
a616174f79
commit
120ed1502b
1 changed files with 21 additions and 15 deletions
36
src/main.rs
36
src/main.rs
|
@ -82,8 +82,8 @@ fn create_tables(conn: &mut Connection) -> rusqlite::Result<()> {
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE mon (
|
CREATE TABLE mon (
|
||||||
name STRING NOT NULL,
|
name STRING NOT NULL,
|
||||||
usage REAL NOT NULL,
|
usage REAL,
|
||||||
viability_ceiling REAL NOT NULL
|
viability_ceiling REAL
|
||||||
);
|
);
|
||||||
CREATE TABLE ability (
|
CREATE TABLE ability (
|
||||||
mon STRING NOT NULL,
|
mon STRING NOT NULL,
|
||||||
|
@ -142,7 +142,11 @@ fn insert_stats(conn: &mut Connection, stats: &Stats) -> rusqlite::Result<()> {
|
||||||
let mon_count: f32 = data.abilities.values().sum();
|
let mon_count: f32 = data.abilities.values().sum();
|
||||||
tx.execute(
|
tx.execute(
|
||||||
"INSERT INTO mon VALUES (?1, ?2, ?3)",
|
"INSERT INTO mon VALUES (?1, ?2, ?3)",
|
||||||
(mon, data.usage, data.viability_ceiling[1]),
|
(
|
||||||
|
mon,
|
||||||
|
data.usage,
|
||||||
|
data.viability_ceiling.as_ref().map(|x| x[1]),
|
||||||
|
),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
for (ability, count) in &data.abilities {
|
for (ability, count) in &data.abilities {
|
||||||
|
@ -166,15 +170,17 @@ fn insert_stats(conn: &mut Connection, stats: &Stats) -> rusqlite::Result<()> {
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tera, count) in &data.tera {
|
if let Some(tera) = &data.tera {
|
||||||
tx.execute(
|
for (tera, count) in tera {
|
||||||
"INSERT INTO tera VALUES (?1, ?2, ?3)",
|
tx.execute(
|
||||||
(
|
"INSERT INTO tera VALUES (?1, ?2, ?3)",
|
||||||
mon,
|
(
|
||||||
format!("{tera:?}").to_ascii_lowercase(),
|
mon,
|
||||||
count / mon_count,
|
format!("{tera:?}").to_ascii_lowercase(),
|
||||||
),
|
count / mon_count,
|
||||||
)?;
|
),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (mate, count) in &data.teammates {
|
for (mate, count) in &data.teammates {
|
||||||
|
@ -242,16 +248,16 @@ type Counts = HashMap<Box<str>, f32>;
|
||||||
#[serde(rename_all = "PascalCase")]
|
#[serde(rename_all = "PascalCase")]
|
||||||
struct Data {
|
struct Data {
|
||||||
#[serde(rename = "Viability Ceiling")]
|
#[serde(rename = "Viability Ceiling")]
|
||||||
viability_ceiling: Box<[u32]>,
|
viability_ceiling: Option<Box<[u32]>>,
|
||||||
abilities: Counts,
|
abilities: Counts,
|
||||||
items: Counts,
|
items: Counts,
|
||||||
moves: Counts,
|
moves: Counts,
|
||||||
#[serde(rename = "Tera Types")]
|
#[serde(rename = "Tera Types")]
|
||||||
tera: HashMap<Type, f32>,
|
tera: Option<HashMap<Type, f32>>,
|
||||||
// i'm just not going to include happiness sorry
|
// i'm just not going to include happiness sorry
|
||||||
teammates: Counts,
|
teammates: Counts,
|
||||||
#[serde(rename = "Checks and Counters")]
|
#[serde(rename = "Checks and Counters")]
|
||||||
checks_and_counters: HashMap<Box<str>, (f32, f32, f32)>,
|
checks_and_counters: HashMap<Box<str>, (f32, f32, f32)>,
|
||||||
#[serde(rename = "usage")]
|
#[serde(rename = "usage")]
|
||||||
usage: f32,
|
usage: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue