This commit is contained in:
parent
9d7eb9f875
commit
c2cb38b703
4 changed files with 8 additions and 21 deletions
|
@ -103,10 +103,7 @@ impl DataSource for CGGDataSource {
|
|||
0
|
||||
}
|
||||
|
||||
fn get_champs_with_positions(
|
||||
&self,
|
||||
client: &ureq::Agent,
|
||||
) -> IndexMap<u32, Vec<String>> {
|
||||
fn get_champs_with_positions(&self, client: &ureq::Agent) -> IndexMap<u32, Vec<String>> {
|
||||
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(),
|
||||
},
|
||||
));
|
||||
}
|
||||
|
|
|
@ -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<u32, Vec<String>>;
|
||||
fn get_champs_with_positions(&self, client: &ureq::Agent) -> IndexMap<u32, Vec<String>>;
|
||||
|
||||
fn get_champ_data_with_win_pourcentage(
|
||||
&self,
|
||||
|
|
|
@ -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<String>,
|
||||
|
|
|
@ -90,7 +90,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.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<dyn std::error::Error>> {
|
|||
.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!(
|
||||
|
|
Loading…
Add table
Reference in a new issue