use champ name for log

This commit is contained in:
nyyu 2018-06-09 11:46:02 +02:00
parent 6947fbe05a
commit 444f6333b5

View file

@ -36,7 +36,7 @@ struct Champion {
#[derive(Deserialize)] #[derive(Deserialize)]
struct ChampInfo { struct ChampInfo {
/*id: String*/ name: String,
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
@ -114,7 +114,14 @@ fn main() {
let path = lol_champs_dir.join(&id).join("Recommended"); let path = lol_champs_dir.join(&id).join("Recommended");
fs::create_dir_all(&path).unwrap(); fs::create_dir_all(&path).unwrap();
for pos in positions { for pos in positions {
write_item_set(&id, &pos, &patch, &path, &client); write_item_set(
&id,
&champion.data.get(id).unwrap().name,
&pos,
&patch,
&path,
&client,
);
thread::sleep(Duration::from_millis(300)); thread::sleep(Duration::from_millis(300));
} }
} else { } else {
@ -205,8 +212,15 @@ fn make_item_set_from_list(list: &Vec<u32>, label: &str, key: &str, data: &Value
}) })
} }
fn write_item_set(id: &str, pos: &str, ver: &str, path: &PathBuf, client: &reqwest::Client) { fn write_item_set(
info!("Retrieving data for {} at {}", id, pos); id: &str,
name: &str,
pos: &str,
ver: &str,
path: &PathBuf,
client: &reqwest::Client,
) {
info!("Retrieving data for {} at {}", name, pos);
let data = get_champ_data(id, pos, client); let data = get_champ_data(id, pos, client);
match data { match data {
@ -247,7 +261,7 @@ fn write_item_set(id: &str, pos: &str, ver: &str, path: &PathBuf, client: &reqwe
&data, &data,
)); ));
info!("Writing item set for {} at {}", id, pos); info!("Writing item set for {} at {}", name, pos);
fs::write( fs::write(
path.join(format!("CGG_{}_{}.json", id, pos)), path.join(format!("CGG_{}_{}.json", id, pos)),
serde_json::to_string_pretty(&item_set).unwrap(), serde_json::to_string_pretty(&item_set).unwrap(),