Skip to content

Commit

Permalink
Some refactoring of recent changes
Browse files Browse the repository at this point in the history
Don't set AllPvp in modes for private matches (to be consistent with API).

Simplify how we get last activity id.
  • Loading branch information
mikechambers committed Dec 14, 2022
1 parent cbf11ac commit b9d36a6
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 42 deletions.
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## v9.93.0

- Added support for Iron Banner Zone Control (iron_banner_zone_control)
- Added code that attempts to fix missing / incorrect mode data for some match returned from API. This includes Season of the Seraph comp match data, as well as data for private matches. In order to get fixed data, you will need to delete your data store and resync once.
- Added code that attempts to fix missing / incorrect mode data for some matches returned from API. This includes Season of the Seraph comp match data, as well as data for private matches. In order to get fixed data, you will need to delete your data store and resync all data.

## v9.91.0 December 6, 2022

Expand Down
18 changes: 9 additions & 9 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dcli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dcli"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
edition = "2018"
description = "Library for the dcli collection of command line tools for Destiny 2."
Expand Down
25 changes: 4 additions & 21 deletions src/dcli/src/activitystoreinterface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use indicatif::{ProgressBar, ProgressState, ProgressStyle};

use crate::enums::moment::Moment;
use crate::playeractivitiessummary::PlayerActivitiesSummary;
use crate::response::activities::DestinyHistoricalStatsActivity;
use crate::utils::{
format_error, COMPETITIVE_PVP_ACTIVITY_HASH,
FREELANCE_COMPETITIVE_PVP_ACTIVITY_HASH,
Expand Down Expand Up @@ -957,12 +956,6 @@ impl ActivityStoreInterface {
_ => was_updated = false,
};

//println!("found private match: updated : {}", was_updated);

if was_updated {
self.add_to_modes(activity, Mode::AllPvP);
}

was_updated
}

Expand Down Expand Up @@ -1491,13 +1484,6 @@ impl ActivityStoreInterface {
character_row_id: i32,
mode: &Mode,
) -> Result<i64, Error> {
let restrict_mode_id = if mode.is_private() {
-1
} else {
//if not private, then we dont include any results that are private
Mode::PrivateMatchesAll.as_id() as i32
};

let rows = sqlx::query(
r#"
SELECT
Expand All @@ -1508,20 +1494,16 @@ impl ActivityStoreInterface {
activity ON activity_queue.activity_id = activity.activity_id,
character_activity_stats ON character_activity_stats.activity = activity.id,
character on character_activity_stats.character = character.id,
modes ON modes.activity = activity.id
modes ON modes.activity = activity.id and modes.mode = ?
WHERE
character_activity_stats.character = ? AND
activity_queue.character = ? AND
exists (select 1 from modes where activity = activity.id and mode = ?) AND
not exists (select 1 from modes where activity = activity.id and mode = ?)
activity_queue.character = ?
ORDER BY activity.period DESC LIMIT 1
"#,
)

.bind(mode.as_id().to_string())
.bind(character_row_id.to_string())
.bind(character_row_id.to_string())
.bind(mode.as_id().to_string())
.bind(restrict_mode_id)
.fetch_all(&mut self.db)
.await?;

Expand All @@ -1531,6 +1513,7 @@ impl ActivityStoreInterface {

let row = &rows[0];
let activity_id: i64 = row.try_get("max_activity_id")?;

Ok(activity_id)
}

Expand Down
4 changes: 3 additions & 1 deletion src/dcli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ pub fn format_error(msg: &str, error: Error) -> String {

strings.push("\nIf you think you have hit a bug and would like to report it (or would just like some help):".to_string());
strings.push(" 1. Run command with '--verbose' flag.".to_string());
strings.push(" 2. Copy output, and log a bug at: ".to_string());
strings.push(" 2a. Copy output, and share on Discord: ".to_string());
strings.push(" https://discord.gg/2Y8bV2Mq3p".to_string());
strings.push(" 2b. Copy output, and log a bug at: ".to_string());
strings
.push(" https://github.com/mikechambers/dcli/issues".to_string());

Expand Down
2 changes: 1 addition & 1 deletion src/dclia/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dclia"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
description = "Command line tool for retrieving information on current activity for specified player character."
homepage = "https://www.mikechambers.com"
Expand Down
2 changes: 1 addition & 1 deletion src/dcliad/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dcliad"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
edition = "2018"
description = "Command line tool for viewing Destiny 2 activity details."
Expand Down
2 changes: 1 addition & 1 deletion src/dcliah/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dcliah"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
edition = "2018"
description = "Command line tool for viewing Destiny 2 activity history."
Expand Down
2 changes: 1 addition & 1 deletion src/dclif/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dclif"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
edition = "2018"
description = "Command line tool for querying specific Destiny 2 pvp stats."
Expand Down
2 changes: 1 addition & 1 deletion src/dclim/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dclim"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
edition = "2018"
description = "Command line tool for managing and syncing the remote Destiny 2 API manifest database."
Expand Down
2 changes: 1 addition & 1 deletion src/dclistat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dclistat"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
edition = "2018"
description = "Command line tool for querying specific Destiny 2 pvp stats."
Expand Down
2 changes: 1 addition & 1 deletion src/dclisync/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dclisync"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
edition = "2018"
description = "Command line tool for downloading and syncing Destiny 2 Crucible activity history."
Expand Down
2 changes: 1 addition & 1 deletion src/dclitime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dclitime"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
edition = "2018"
description = "Command line tool for retrieving Destiny 2 related date / time stamps"
Expand Down
2 changes: 1 addition & 1 deletion src/tell/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tell"
#version
version = "0.91.0"
version = "0.93.0"
authors = ["Mike Chambers <[email protected]>"]
edition = "2018"
description = "Simple library for handling different levels of user output for command line apps."
Expand Down

0 comments on commit b9d36a6

Please sign in to comment.