From c2cb38b703d81774e27f54505621671ca33921c6 Mon Sep 17 00:00:00 2001 From: nyyu Date: Wed, 17 Mar 2021 09:13:19 +0100 Subject: [PATCH] Fix format --- src/cgg_data_source.rs | 11 +++-------- src/data_source.rs | 7 ++----- src/kb_data_source.rs | 2 +- src/main.rs | 9 ++------- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/cgg_data_source.rs b/src/cgg_data_source.rs index 2398047..b3d3fcc 100644 --- a/src/cgg_data_source.rs +++ b/src/cgg_data_source.rs @@ -103,10 +103,7 @@ impl DataSource for CGGDataSource { 0 } - fn get_champs_with_positions( - &self, - client: &ureq::Agent, - ) -> IndexMap> { + fn get_champs_with_positions(&self, client: &ureq::Agent) -> IndexMap> { let req = client.get("https://champion.gg").call().unwrap(); let page = &req.into_string().unwrap(); @@ -153,9 +150,7 @@ impl DataSource for CGGDataSource { let mut some_champ: Option<&ChampionReport> = None; let reports = CHAMPIONS_REPORT.lock().unwrap(); for champion in reports.iter() { - if champion.champion_id.to_string() == champ.key - && champion.role == *position - { + if champion.champion_id.to_string() == champ.key && champion.role == *position { some_champ = Some(champion); break; } @@ -205,7 +200,7 @@ impl DataSource for CGGDataSource { win_rate: stat.win_rate.unwrap(), games: stat.games.unwrap(), kda: stat.kda.unwrap(), - patch: champ.patch.to_owned() + patch: champ.patch.to_owned(), }, )); } diff --git a/src/data_source.rs b/src/data_source.rs index ce37aa8..4ad3ed4 100644 --- a/src/data_source.rs +++ b/src/data_source.rs @@ -35,7 +35,7 @@ pub struct Stat { pub win_rate: f64, pub games: u32, pub kda: f64, - pub patch: String + pub patch: String, } pub trait DataSource { @@ -43,10 +43,7 @@ pub trait DataSource { fn get_timeout(&self) -> u64; - fn get_champs_with_positions( - &self, - client: &ureq::Agent, - ) -> IndexMap>; + fn get_champs_with_positions(&self, client: &ureq::Agent) -> IndexMap>; fn get_champ_data_with_win_pourcentage( &self, diff --git a/src/kb_data_source.rs b/src/kb_data_source.rs index bd9907d..ce23c3d 100644 --- a/src/kb_data_source.rs +++ b/src/kb_data_source.rs @@ -1,11 +1,11 @@ use crate::data_source::{Build, DataSource, Item, Stat}; use crate::ChampInfo; +use crate::USER_AGENT_VALUE; use indexmap::IndexMap; use lazy_static::lazy_static; use serde_derive::Deserialize; use serde_json::{json, Value}; use std::time::Duration; -use crate::USER_AGENT_VALUE; pub struct KBDataSource { token: Option, diff --git a/src/main.rs b/src/main.rs index 0156b28..7e666ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,7 +90,6 @@ fn main() -> Result<(), Box> { .call()? .into_json()?; info!("LoL version: {}", realm.v); - let champion: Champion = client .get(&format!( "https://ddragon.leagueoflegends.com/cdn/{}/data/en_US/champion.json", @@ -100,13 +99,9 @@ fn main() -> Result<(), Box> { .into_json()?; info!("LoL numbers of champs: {}", champion.data.len()); - let data_sources: [&'static (dyn DataSource + Sync + Send); 3] = [ - &PBDataSource, - &CGGDataSource, - KBDataSource::new(), - ]; + let data_sources: [&'static (dyn DataSource + Sync + Send); 3] = + [&PBDataSource, &CGGDataSource, KBDataSource::new()]; data_sources.par_iter().for_each(|data_source| { - let init = Instant::now(); execute_data_source(*data_source, &client, &champion, &lol_champs_dir); info!(