oops format
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
nyyu 2021-03-16 20:25:14 +01:00
parent 245e9c8628
commit bdf6f97923

View file

@ -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
@ -68,10 +66,10 @@ impl DataSource for PBDataSource {
let mut build = &page[page.find("'items'").unwrap()..]; let mut build = &page[page.find("'items'").unwrap()..];
while build.contains("items") { while build.contains("items") {
let pos = build.find("data-id=").unwrap(); let pos = build.find("data-id=").unwrap();
build = &build[pos+10..]; build = &build[pos + 10..];
let end = build.find('\\').unwrap(); let end = build.find('\\').unwrap();
items.push(&build[..end]); items.push(&build[..end]);
build = &build[pos+22..]; build = &build[pos + 22..];
} }
builds.push((positions[0].to_owned(), vec![json!({ builds.push((positions[0].to_owned(), vec![json!({
@ -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
} }
} }