Skip to content

Commit 4bcbcd1

Browse files
committed
Update to v0.8.5. Add check for ENV variable to fix corrupt data
If the `DCLI_FIX_DATA` environment variable is set to `TRUE` then when corrupt or missing data is returned from the Bungie API, and there is not a valid local version, DCLI will attempt to retrieve updated, non-corrupt data from Bungie. (This sometimes happens if a lot of people leave a game, and no player names will be returned from the server). Setting this to true can significantly slow down sync time, especially the initial sync, and in general, is meant to be used when using DCLI to create datastores for larger applications.
1 parent 395a65e commit 4bcbcd1

File tree

12 files changed

+125
-86
lines changed

12 files changed

+125
-86
lines changed

README.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ dcli (Destiny Command Line Interface) is a collection of utilities and apps that
77

88
If you run into any issues, have any ideas, or just want to chat, please post in [issues](https://github.com/mikechambers/dcli/issues) or share on [Discord](https://discord.gg/2Y8bV2Mq3p)
99

10-
1110
## Apps
1211

1312
### Utilities
14-
| TOOL | DESCRIPTION |
15-
| --- | --- |
16-
| [dclim](https://github.com/mikechambers/dcli/tree/main/src/dclim) | Manages and syncs the remote Destiny 2 API manifest database |
17-
| [dclisync](https://github.com/mikechambers/dcli/tree/main/src/dclisync) | Downloads and syncs Destiny 2 Crucible activity history into a local sqlite3 database file |
18-
| [dclitime](https://github.com/mikechambers/dcli/tree/main/src/dclitime) | Generates date / time stamps for Destiny 2 weekly event moments |
1913

14+
| TOOL | DESCRIPTION |
15+
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
16+
| [dclim](https://github.com/mikechambers/dcli/tree/main/src/dclim) | Manages and syncs the remote Destiny 2 API manifest database |
17+
| [dclisync](https://github.com/mikechambers/dcli/tree/main/src/dclisync) | Downloads and syncs Destiny 2 Crucible activity history into a local sqlite3 database file |
18+
| [dclitime](https://github.com/mikechambers/dcli/tree/main/src/dclitime) | Generates date / time stamps for Destiny 2 weekly event moments |
2019

2120
### Apps
22-
| TOOL | DESCRIPTION |
23-
| --- | --- |
24-
| [dclia](https://github.com/mikechambers/dcli/tree/main/src/dclia) | Displays information on player's current activity within Destiny 2 |
25-
| [dcliah](https://github.com/mikechambers/dcli/tree/main/src/dcliah) | Displays Destiny 2 activity history and stats |
26-
| [dcliad](https://github.com/mikechambers/dcli/tree/main/src/dcliad) | Displays Destiny 2 Crucible activity / match details |
2721

22+
| TOOL | DESCRIPTION |
23+
| ------------------------------------------------------------------- | ------------------------------------------------------------------ |
24+
| [dclia](https://github.com/mikechambers/dcli/tree/main/src/dclia) | Displays information on player's current activity within Destiny 2 |
25+
| [dcliah](https://github.com/mikechambers/dcli/tree/main/src/dcliah) | Displays Destiny 2 activity history and stats |
26+
| [dcliad](https://github.com/mikechambers/dcli/tree/main/src/dcliad) | Displays Destiny 2 Crucible activity / match details |
2827

2928
### Libraries
30-
| TOOL | DESCRIPTION |
31-
| --- | --- |
29+
30+
| TOOL | DESCRIPTION |
31+
| --------------------------------------------------------------- | ---------------------------------------- |
3232
| [dcli](https://github.com/mikechambers/dcli/tree/main/src/dcli) | Library used across all of the dcli apps |
3333

3434
Each tool page contains additional tool specific information and usage examples.
@@ -55,7 +55,6 @@ If you are running on Mac, make sure to [read this article](https://github.com/m
5555

5656
Before viewing your stats you need to first sync the manifest (which contains information about weapons, maps, etc...).
5757

58-
5958
### Download the manifest
6059

6160
You can download the latest Destiny 2 manifest database using dclim. This contains information about all of the items and activities in Destiny 2, and is updated periodically.
@@ -73,7 +72,7 @@ and the manifest file will be downloaded and saved in a system appropriate direc
7372
Next, lets sync all of our activity history to a local database and view data. This data will be used by other apps, such as dcliah to generate and display stats.
7473

7574
```
76-
$ dcliah --name mesh#3230
75+
$ dcliah --name mesh#3230
7776
```
7877

7978
Replacing mesh#3230 with your own Bungie name.
@@ -106,15 +105,15 @@ These can be useful on their own, but where they can be really powerful is when
106105

107106
There are a couple of examples in the [examples directory](https://github.com/mikechambers/dcli/tree/main/examples):
108107

109-
* Send a notification when you load into a new activity (particularly useful when playing crucible so you can see which map you are loading into)
110-
* Automatically generate weekly reports on your Crucible stats and email them to yourself
111-
* Track your Crucible stats per game play session
108+
- Send a notification when you load into a new activity (particularly useful when playing crucible so you can see which map you are loading into)
109+
- Automatically generate weekly reports on your Crucible stats and email them to yourself
110+
- Track your Crucible stats per game play session
112111

113112
As you can see, right now, a lot of the functionality is Crucible based. If you would like to see other functionality, make sure you requests it in the [issues](https://github.com/mikechambers/dcli/issues), or [Discord](https://discord.gg/2Y8bV2Mq3p).
114113

115114
### Learning More
116115

117-
At anytime, you can see which arguments and options are avaliable by passing the *--help* argument:
116+
At anytime, you can see which arguments and options are avaliable by passing the _--help_ argument:
118117

119118
```
120119
$ dcliah --help
@@ -128,6 +127,12 @@ If you have any questions, feature requests, need help, or just want to chat, jo
128127

129128
You can also log bugs and features requests on the [issues page](https://github.com/mikechambers/dcli/issues).
130129

130+
### Environment Variables
131+
132+
If the `DCLI_FIX_DATA` environment variable is set to `TRUE` then when corrupt or missing data is returned from the Bungie API, and there is not a valid local version, DCLI will attempt to retrieve updated, non-corrupt data from Bungie. (This sometimes happens if a lot of people leave a game, and no player names will be returned from the server).
133+
134+
Setting this to true can significantly slow down sync time, especially the initial sync, and in general, is meant to be used when using DCLI to create datastores for larger applications.
135+
131136
## Compiling
132137

133138
Tools are written and compiled in [Rust](https://www.rust-lang.org/). The 1.50.0 rust version is required, which can be installed and set via:
@@ -147,11 +152,11 @@ To compile, switch to the `src/` directory and run:
147152
$ cargo build --release
148153
```
149154

150-
which will place the compiled tools in *src/target/release*
155+
which will place the compiled tools in _src/target/release_
151156

152157
## Known Issues
153158

154-
* Tied matches are not displayed correctly, and are treated as a Victory.
159+
- Tied matches are not displayed correctly, and are treated as a Victory.
155160

156161
## License
157162

RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# dcli Release Notes
22

3+
## v0.8.5 August 7, 2022
4+
5+
- Improved how corrupted data from Bungie is handled. Now, if data is corrupted, we check for existing data before updating. If the DCLI_FIX_DATA environment variable is set to true, then if there is not already a local, non-corrupt version of the data, we will go back to Bungie to retrieve updated data. Note, this can significantly slow down initial syncs.
6+
37
## v0.8.4 August 1, 2022
48

59
- Fixed data parsing error that could occur due to wrong data type in code

src/Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dcli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dcli"
33
#version
4-
version = "0.8.4"
4+
version = "0.8.5"
55
authors = ["Mike Chambers <mikechambers@gmail.com>"]
66
edition = "2018"
77
description = "Library for the dcli collection of command line tools for Destiny 2."

src/dcli/src/activitystoreinterface.rs

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use std::{collections::HashMap, path::Path};
2626
use chrono::{DateTime, Utc};
2727

2828
use crate::response::character::CharacterData;
29-
use crate::response::gmd::UserMembershipData;
3029
use crate::utils::calculate_percent;
3130
use crate::{
3231
crucible::{CrucibleActivity, Member, PlayerName, Team},
@@ -64,9 +63,13 @@ use crate::{
6463
},
6564
};
6665

66+
use std::env;
67+
6768
const STORE_FILE_NAME: &str = "dcli.sqlite3";
6869
const STORE_DB_SCHEMA: &str = include_str!("../actitvity_store_schema.sql");
6970

71+
const DCLI_FIX_DATA: &str = "DCLI_FIX_DATA";
72+
7073
//numer of simultaneous requests we make to server when retrieving activity history
7174
const PGCR_REQUEST_CHUNK_AMOUNT: usize = 24;
7275

@@ -78,6 +81,7 @@ pub struct ActivityStoreInterface {
7881
db: SqliteConnection,
7982
path: String,
8083
api_interface: ApiInterface,
84+
fix_corrupt_data: bool,
8185
}
8286

8387
impl ActivityStoreInterface {
@@ -92,6 +96,18 @@ impl ActivityStoreInterface {
9296
) -> Result<ActivityStoreInterface, Error> {
9397
let path = store_dir.join(STORE_FILE_NAME).display().to_string();
9498

99+
let fix_corrupt_data = match env::var(DCLI_FIX_DATA) {
100+
Ok(v) => v.to_lowercase() == "true",
101+
Err(_e) => false,
102+
};
103+
104+
if verbose {
105+
println!(
106+
"DCLI_FIX_DATA environment variable enabled : {}",
107+
fix_corrupt_data
108+
);
109+
}
110+
95111
let read_only = false;
96112
let connection_string: &str = &path;
97113

@@ -135,6 +151,7 @@ impl ActivityStoreInterface {
135151
verbose,
136152
path: path.to_string(),
137153
api_interface,
154+
fix_corrupt_data,
138155
})
139156
}
140157

@@ -1125,11 +1142,11 @@ impl ActivityStoreInterface {
11251142
let mut member = mem;
11261143
let mut m = None;
11271144
//check and see if data is missing (happens a lot with the API)
1128-
if member.name.display_name.is_none()
1145+
if member.name.bungie_display_name.is_none()
11291146
|| member.name.bungie_display_name_code.is_none()
11301147
|| member.platform == Platform::Unknown
11311148
{
1132-
//if some data is missing, the see if we already have info on
1149+
//if some data is missing, we see if we already have info on
11331150
//this member stored.
11341151

11351152
let row_id: i32 = match self.get_member_row_id(member).await {
@@ -1143,27 +1160,33 @@ impl ActivityStoreInterface {
11431160
return Ok(row_id);
11441161
}
11451162

1146-
//need to catch and ignore error here
1147-
let card_result = self
1148-
.api_interface
1149-
.retrieve_player_info_by_id(&member.id)
1150-
.await;
1151-
1152-
if card_result.is_ok() {
1153-
let c = card_result.unwrap();
1154-
let cards = c.destiny_memberships;
1155-
1156-
for card in cards.iter() {
1157-
if card.cross_save_override == card.membership_type {
1158-
m = Some(card.to_member());
1159-
break;
1163+
//if the DCLI_FIX_DATA environemnt variable is set to true
1164+
//the code will try and fix corrupt data with additional API
1165+
//calls. This can dramatically slow down the first time data is
1166+
//synced, but can help fix missing data
1167+
if self.fix_corrupt_data {
1168+
//need to catch and ignore error here
1169+
let card_result = self
1170+
.api_interface
1171+
.retrieve_player_info_by_id(&member.id)
1172+
.await;
1173+
1174+
if card_result.is_ok() {
1175+
let c = card_result.unwrap();
1176+
let cards = c.destiny_memberships;
1177+
1178+
for card in cards.iter() {
1179+
if card.cross_save_override == card.membership_type {
1180+
m = Some(card.to_member());
1181+
break;
1182+
}
11601183
}
1161-
}
11621184

1163-
//if we get here, then we need to go to the server to try and get the
1164-
//data
1165-
if m.is_some() {
1166-
member = m.as_ref().unwrap();
1185+
//if we get here, then we need to go to the server to try and get the
1186+
//data
1187+
if m.is_some() {
1188+
member = m.as_ref().unwrap();
1189+
}
11671190
}
11681191
}
11691192
}
@@ -1172,7 +1195,7 @@ impl ActivityStoreInterface {
11721195
r#"
11731196
INSERT into "member" ("member_id", "platform_id", "display_name", "bungie_display_name", "bungie_display_name_code") VALUES (?, ?, ?, ?, ?)
11741197
ON CONFLICT(member_id) DO UPDATE
1175-
set display_name = ?, bungie_display_name = ?, bungie_display_name_code = ?
1198+
set display_name = ?, bungie_display_name = ?, bungie_display_name_code = ?, platform_id = ?
11761199
"#,
11771200
)
11781201
.bind(member.id.to_string())
@@ -1183,6 +1206,7 @@ impl ActivityStoreInterface {
11831206
.bind(&member.name.display_name)
11841207
.bind(&member.name.bungie_display_name)
11851208
.bind(&member.name.bungie_display_name_code)
1209+
.bind(member.platform.as_id().to_string())
11861210
.execute(&mut self.db)
11871211
.await?;
11881212

src/dclia/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dclia"
33
#version
4-
version = "0.8.4"
4+
version = "0.8.5"
55
authors = ["Mike Chambers <mikechambers@gmail.com>"]
66
description = "Command line tool for retrieving information on current activity for specified player character."
77
homepage = "https://www.mikechambers.com"

src/dcliad/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dcliad"
33
#version
4-
version = "0.8.4"
4+
version = "0.8.5"
55
authors = ["Mike Chambers <mikechambers@gmail.com>"]
66
edition = "2018"
77
description = "Command line tool for viewing Destiny 2 activity details."

src/dcliah/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dcliah"
33
#version
4-
version = "0.8.4"
4+
version = "0.8.5"
55
authors = ["Mike Chambers <mikechambers@gmail.com>"]
66
edition = "2018"
77
description = "Command line tool for viewing Destiny 2 activity history."

src/dclim/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dclim"
33
#version
4-
version = "0.8.4"
4+
version = "0.8.5"
55
authors = ["Mike Chambers <mikechambers@gmail.com>"]
66
edition = "2018"
77
description = "Command line tool for managing and syncing the remote Destiny 2 API manifest database."

src/dclisync/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dclisync"
33
#version
4-
version = "0.8.4"
4+
version = "0.8.5"
55
authors = ["Mike Chambers <mikechambers@gmail.com>"]
66
edition = "2018"
77
description = "Command line tool for downloading and syncing Destiny 2 Crucible activity history."

0 commit comments

Comments
 (0)