This commit is contained in:
parent
245e9c8628
commit
bdf6f97923
1 changed files with 11 additions and 14 deletions
|
@ -15,7 +15,7 @@ struct ChampionResponse {
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
struct Champion {
|
struct Champion {
|
||||||
key: String,
|
key: String,
|
||||||
name: String
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DataSource for PBDataSource {
|
impl DataSource for PBDataSource {
|
||||||
|
@ -29,19 +29,18 @@ impl DataSource for PBDataSource {
|
||||||
300
|
300
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_champs_with_positions(
|
fn get_champs_with_positions(&self, client: &ureq::Agent) -> IndexMap<u32, Vec<String>> {
|
||||||
&self,
|
|
||||||
client: &ureq::Agent,
|
|
||||||
) -> IndexMap<u32, Vec<String>> {
|
|
||||||
let mut champs = IndexMap::new();
|
let mut champs = IndexMap::new();
|
||||||
|
|
||||||
let page = client
|
let page = client
|
||||||
.get("https://www.probuilds.net/ajax/championListNew")
|
.get("https://www.probuilds.net/ajax/championListNew")
|
||||||
.set("Accept", "application/json")
|
.set("Accept", "application/json")
|
||||||
.call().unwrap().into_string().unwrap();
|
.call()
|
||||||
|
.unwrap()
|
||||||
|
.into_string()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let data: ChampionResponse =
|
let data: ChampionResponse = serde_json::from_str(&page).unwrap();
|
||||||
serde_json::from_str(&page).unwrap();
|
|
||||||
|
|
||||||
for champ in data.champions {
|
for champ in data.champions {
|
||||||
champs.insert(champ.key.parse::<u32>().unwrap(), vec!["ANY".to_owned()]);
|
champs.insert(champ.key.parse::<u32>().unwrap(), vec!["ANY".to_owned()]);
|
||||||
|
@ -56,7 +55,6 @@ impl DataSource for PBDataSource {
|
||||||
positions: &[String],
|
positions: &[String],
|
||||||
client: &ureq::Agent,
|
client: &ureq::Agent,
|
||||||
) -> Vec<(String, Vec<Value>, Stat)> {
|
) -> Vec<(String, Vec<Value>, Stat)> {
|
||||||
|
|
||||||
let mut builds = vec![];
|
let mut builds = vec![];
|
||||||
|
|
||||||
let page = client
|
let page = client
|
||||||
|
@ -79,7 +77,6 @@ impl DataSource for PBDataSource {
|
||||||
"type": "Set"
|
"type": "Set"
|
||||||
})], Stat{win_rate:0.0,games:1,kda:0.0,patch:"".to_string()}));
|
})], Stat{win_rate:0.0,games:1,kda:0.0,patch:"".to_string()}));
|
||||||
|
|
||||||
|
|
||||||
builds
|
builds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue