This commit is contained in:
nyyu 2019-04-21 22:34:08 +02:00
parent d9da160e3f
commit fa34717836
2 changed files with 12 additions and 8 deletions

View file

@ -47,9 +47,9 @@ pub trait DataSource {
fn make_item_set(&self, data: &Value, label: &str) -> Value {
json!({
"items": data["items"].as_array().unwrap().iter().map(|x| json!({"id": x["id"].as_str(), "count": 1})).collect::<Vec<Value>>(),
"type": format!("{} ({:.2}% - {} games)", label, data["winPercent"].as_f64().unwrap() * 100., data["games"].as_u64().unwrap())
})
"items": data["items"].as_array().unwrap().iter().map(|x| json!({"id": x["id"].as_str(), "count": 1})).collect::<Vec<Value>>(),
"type": format!("{} ({:.2}% - {} games)", label, data["winPercent"].as_f64().unwrap() * 100., data["games"].as_u64().unwrap())
})
}
fn make_item_set_from_list(
@ -75,9 +75,9 @@ pub trait DataSource {
.join(".");
}
json!({
"items": list.iter().map(|x| json!({"id": x.to_string(), "count": 1})).collect::<Vec<Value>>(),
"type": format!("{} {}", label, key_order)
})
"items": list.iter().map(|x| json!({"id": x.to_string(), "count": 1})).collect::<Vec<Value>>(),
"type": format!("{} {}", label, key_order)
})
}
fn write_item_set(
&self,
@ -133,7 +133,8 @@ pub trait DataSource {
fs::write(
path.join(format!("CGG_{}_{}.json", id, pos)),
serde_json::to_string_pretty(&item_set).unwrap(),
).unwrap();
)
.unwrap();
}
None => {
error!("Can't get data for {} at {}", id, pos);

View file

@ -60,7 +60,10 @@ fn main() {
info!("LoL Champs Folder: {}", lol_champs_dir.to_str().unwrap());
let mut headers = header::HeaderMap::new();
headers.insert(header::USER_AGENT, header::HeaderValue::from_static(USER_AGENT));
headers.insert(
header::USER_AGENT,
header::HeaderValue::from_static(USER_AGENT),
);
let client = reqwest::Client::builder()
.default_headers(headers)