diff --git a/RELEASE.md b/RELEASE.md index a0ef83dc..6ddb94b7 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,9 @@ # dcli Release Notes +## v0.95.0 December 17, 2022 + +- Improved handling of missing character class data from API + ## v0.94.0 December 13, 2022 - Fix corrupted Rift matches (mode set to 0) diff --git a/src/Cargo.lock b/src/Cargo.lock index 0346f2eb..3e0b9ccd 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -367,7 +367,7 @@ dependencies = [ [[package]] name = "dcli" -version = "0.94.0" +version = "0.95.0" dependencies = [ "chrono", "crossterm", @@ -389,7 +389,7 @@ dependencies = [ [[package]] name = "dclia" -version = "0.94.0" +version = "0.95.0" dependencies = [ "dcli", "env_logger", @@ -401,7 +401,7 @@ dependencies = [ [[package]] name = "dcliad" -version = "0.94.0" +version = "0.95.0" dependencies = [ "dcli", "env_logger", @@ -413,7 +413,7 @@ dependencies = [ [[package]] name = "dcliah" -version = "0.94.0" +version = "0.95.0" dependencies = [ "chrono", "dcli", @@ -427,7 +427,7 @@ dependencies = [ [[package]] name = "dclim" -version = "0.94.0" +version = "0.95.0" dependencies = [ "dcli", "env_logger", @@ -444,7 +444,7 @@ dependencies = [ [[package]] name = "dclistat" -version = "0.94.0" +version = "0.95.0" dependencies = [ "chrono", "dcli", @@ -458,7 +458,7 @@ dependencies = [ [[package]] name = "dclisync" -version = "0.94.0" +version = "0.95.0" dependencies = [ "ctrlc", "dcli", @@ -472,7 +472,7 @@ dependencies = [ [[package]] name = "dclitime" -version = "0.94.0" +version = "0.95.0" dependencies = [ "chrono", "dcli", @@ -1905,7 +1905,7 @@ dependencies = [ [[package]] name = "tell" -version = "0.94.0" +version = "0.95.0" dependencies = [ "lazy_static", ] diff --git a/src/dcli/Cargo.toml b/src/dcli/Cargo.toml index ca7991e2..9d92800f 100644 --- a/src/dcli/Cargo.toml +++ b/src/dcli/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dcli" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] edition = "2018" description = "Library for the dcli collection of command line tools for Destiny 2." diff --git a/src/dcli/src/activitystoreinterface.rs b/src/dcli/src/activitystoreinterface.rs index d7698314..1415d13b 100644 --- a/src/dcli/src/activitystoreinterface.rs +++ b/src/dcli/src/activitystoreinterface.rs @@ -1367,18 +1367,12 @@ impl ActivityStoreInterface { //if some data is missing, we see if we already have info on //this member stored. - let row_id: i32 = match self.get_member_row_id(member).await { - Ok(e) => e, - Err(_e) => -1, + match self.get_member_row_id(member).await { + Ok(e) => return Ok(e), + Err(_e) => {} }; - //if we do have something stored, just return that entry, otherwise, - //add it to the DB, even though the name info in missing - if row_id != -1 { - return Ok(row_id); - } - - //if the DCLI_FIX_DATA environemnt variable is set to true + //if the DCLI_FIX_DATA environment variable is set to true //the code will try and fix corrupt data with additional API //calls. This can dramatically slow down the first time data is //synced, but can help fix missing data @@ -1428,9 +1422,9 @@ impl ActivityStoreInterface { .execute(&mut self.db) .await?; - let rowid: i32 = self.get_member_row_id(member).await?; + let row_id: i32 = self.get_member_row_id(member).await?; - Ok(rowid) + Ok(row_id) } async fn get_member_row_id( @@ -1457,6 +1451,29 @@ impl ActivityStoreInterface { class_type: &CharacterClass, member_rowid: i32, ) -> Result { + // Check if clas_type is Unknown (Missing data in API) + // If it is, then first see if we already have the character in the DB + // and if so, just return that row. That way, once we have valid data + // in the db, we never overwrite it with invalid data + if *class_type == CharacterClass::Unknown { + match sqlx::query( + r#" + SELECT id from "character" where character_id=? and member=? + "#, + ) + .bind(character_id.to_string()) + .bind(format!("{}", member_rowid)) + .fetch_one(&mut self.db) + .await + { + Ok(e) => { + let id: i32 = e.try_get("id")?; + return Ok(id); + } + Err(_e) => {} + }; + } + sqlx::query( r#" INSERT OR IGNORE into "character" ("character_id", "member", "class") VALUES (?, ?, ?) @@ -1478,9 +1495,9 @@ impl ActivityStoreInterface { .fetch_one(&mut self.db) .await?; - let rowid: i32 = row.try_get("id")?; + let row_id: i32 = row.try_get("id")?; - Ok(rowid) + Ok(row_id) } async fn get_max_activity_id( diff --git a/src/dclia/Cargo.toml b/src/dclia/Cargo.toml index 6f2b2e5c..4f29d868 100644 --- a/src/dclia/Cargo.toml +++ b/src/dclia/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dclia" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] description = "Command line tool for retrieving information on current activity for specified player character." homepage = "https://www.mikechambers.com" diff --git a/src/dcliad/Cargo.toml b/src/dcliad/Cargo.toml index 9b1a2505..19abca47 100644 --- a/src/dcliad/Cargo.toml +++ b/src/dcliad/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dcliad" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] edition = "2018" description = "Command line tool for viewing Destiny 2 activity details." diff --git a/src/dcliah/Cargo.toml b/src/dcliah/Cargo.toml index 8d38b6f8..0f0605b5 100644 --- a/src/dcliah/Cargo.toml +++ b/src/dcliah/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dcliah" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] edition = "2018" description = "Command line tool for viewing Destiny 2 activity history." diff --git a/src/dclif/Cargo.toml b/src/dclif/Cargo.toml index 120e9dad..49c1ce64 100644 --- a/src/dclif/Cargo.toml +++ b/src/dclif/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dclif" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] edition = "2018" description = "Command line tool for querying specific Destiny 2 pvp stats." diff --git a/src/dclim/Cargo.toml b/src/dclim/Cargo.toml index 77df71c7..2b868809 100644 --- a/src/dclim/Cargo.toml +++ b/src/dclim/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dclim" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] edition = "2018" description = "Command line tool for managing and syncing the remote Destiny 2 API manifest database." diff --git a/src/dclistat/Cargo.toml b/src/dclistat/Cargo.toml index 31d41490..e6a1643e 100644 --- a/src/dclistat/Cargo.toml +++ b/src/dclistat/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dclistat" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] edition = "2018" description = "Command line tool for querying specific Destiny 2 pvp stats." diff --git a/src/dclisync/Cargo.toml b/src/dclisync/Cargo.toml index a9344796..f281ad61 100644 --- a/src/dclisync/Cargo.toml +++ b/src/dclisync/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dclisync" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] edition = "2018" description = "Command line tool for downloading and syncing Destiny 2 Crucible activity history." diff --git a/src/dclitime/Cargo.toml b/src/dclitime/Cargo.toml index 510b4e79..2be9f968 100644 --- a/src/dclitime/Cargo.toml +++ b/src/dclitime/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dclitime" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] edition = "2018" description = "Command line tool for retrieving Destiny 2 related date / time stamps" diff --git a/src/tell/Cargo.toml b/src/tell/Cargo.toml index 8e3a917d..14473a60 100644 --- a/src/tell/Cargo.toml +++ b/src/tell/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tell" #version -version = "0.94.0" +version = "0.95.0" authors = ["Mike Chambers "] edition = "2018" description = "Simple library for handling different levels of user output for command line apps."