remove bloat and fix error champion gg if fail
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fdf65c0963
commit
5ee2d9dad2
3 changed files with 44 additions and 46 deletions
22
Cargo.lock
generated
22
Cargo.lock
generated
|
@ -139,15 +139,6 @@ version = "1.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "encoding_rs"
|
|
||||||
version = "0.8.28"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -198,9 +189,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "0.4.7"
|
version = "0.4.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
|
@ -383,15 +374,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.127"
|
version = "1.0.128"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8"
|
checksum = "1056a0db1978e9dbf0f6e4fca677f6f9143dc1c19de346f22cac23e422196834"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.127"
|
version = "1.0.128"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc"
|
checksum = "13af2fbb8b60a8950d6c72a56d2095c28870367cc8e10c55e9745bac4995a2c4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -501,7 +492,6 @@ checksum = "2475a6781e9bc546e7b64f4013d2f4032c8c6a40fcffd7c6f4ee734a890972ab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"chunked_transfer",
|
"chunked_transfer",
|
||||||
"encoding_rs",
|
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustls",
|
"rustls",
|
||||||
|
|
|
@ -4,6 +4,7 @@ edition = "2018"
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
name = "cggitem_sets"
|
name = "cggitem_sets"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
include = ["src/**/*"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
indexmap = {version = "1.6", features = ["serde-1", "rayon"]}
|
indexmap = {version = "1.6", features = ["serde-1", "rayon"]}
|
||||||
|
@ -14,7 +15,7 @@ serde = "1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
serde_json = {version = "1.0", features = ["preserve_order"]}
|
serde_json = {version = "1.0", features = ["preserve_order"]}
|
||||||
simple_logger = "1.11"
|
simple_logger = "1.11"
|
||||||
ureq = {version = "2.0", features = ["json", "charset"]}
|
ureq = {version = "2.0", features = ["json"]}
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winreg = "0.8"
|
winreg = "0.8"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use log::error;
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -109,14 +110,20 @@ impl DataSource for CGGDataSource {
|
||||||
client: &ureq::Agent,
|
client: &ureq::Agent,
|
||||||
_champion: &Champion,
|
_champion: &Champion,
|
||||||
) -> IndexMap<u32, Vec<String>> {
|
) -> IndexMap<u32, Vec<String>> {
|
||||||
let req = client.get("https://champion.gg").call().unwrap();
|
let mut champions: IndexMap<u32, Vec<String>> = IndexMap::new();
|
||||||
|
|
||||||
|
match client.get("https://champion.gg").call() {
|
||||||
|
Ok(req) => {
|
||||||
let page = &req.into_string().unwrap();
|
let page = &req.into_string().unwrap();
|
||||||
|
|
||||||
let datas: BuildResponse =
|
let datas: BuildResponse =
|
||||||
serde_json::from_str(&extract_json("window.__PRELOADED_STATE__ = ", page)).unwrap();
|
serde_json::from_str(&extract_json("window.__PRELOADED_STATE__ = ", page))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let champs_stats: HashMap<String, ChampStat> =
|
let champs_stats: HashMap<String, ChampStat> = serde_json::from_str(&extract_json(
|
||||||
serde_json::from_str(&extract_json("window.__FLASH_CMS_APOLLO_STATE__ = ", page))
|
"window.__FLASH_CMS_APOLLO_STATE__ = ",
|
||||||
|
page,
|
||||||
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
for entry in champs_stats.iter() {
|
for entry in champs_stats.iter() {
|
||||||
CHAMPIONS_STATS
|
CHAMPIONS_STATS
|
||||||
|
@ -124,8 +131,6 @@ impl DataSource for CGGDataSource {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(entry.0.to_owned(), entry.1.to_owned());
|
.insert(entry.0.to_owned(), entry.1.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut champions: IndexMap<u32, Vec<String>> = IndexMap::new();
|
|
||||||
for champ in &datas.lol.champions_report {
|
for champ in &datas.lol.champions_report {
|
||||||
let id = champ.champion_id;
|
let id = champ.champion_id;
|
||||||
if champions.contains_key(&id) {
|
if champions.contains_key(&id) {
|
||||||
|
@ -140,7 +145,9 @@ impl DataSource for CGGDataSource {
|
||||||
for report in datas.lol.champions_report {
|
for report in datas.lol.champions_report {
|
||||||
CHAMPIONS_REPORT.lock().unwrap().push(report);
|
CHAMPIONS_REPORT.lock().unwrap().push(report);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Err(e) => error!("Error retrieving data: {}", e),
|
||||||
|
}
|
||||||
champions
|
champions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue