Fix roles
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nyyu 2021-03-14 09:24:09 +01:00
parent b8b6d78951
commit 0c83809911

View File

@ -103,13 +103,22 @@ impl DataSource for CGGDataSource {
let datas: BuildResponse =
serde_json::from_str(&RE.captures(&req.into_string().unwrap()).unwrap()[1].replace("undefined", "null")).unwrap();
let patch = String::from(datas.lol.champions_report[0].patch.as_str());
let patch = datas.lol.champions_report[0].patch.clone();
let mut champions = IndexMap::new();
let mut champions: IndexMap<String, Vec<String>> = IndexMap::new();
for champ in &datas.lol.champions_report {
let id = champ.champion_id.to_string();
let positions = [String::from(&champ.role)].to_vec();
champions.insert(id, positions);
let mut roles: Vec<String> = Vec::new();
if champions.contains_key(&id) {
let c = champions.get(&id).unwrap();
let mut new_roles = c.clone();
new_roles.push(champ.role.clone());
} else {
roles.push(champ.role.clone());
}
champions.insert(id, roles);
}
unsafe {