1
0
Fork 0
This commit is contained in:
ChaotiCryptidz 2022-08-22 21:35:49 +01:00
parent c50dc62121
commit 1d3f6df896
No known key found for this signature in database

View file

@ -9,48 +9,46 @@ pub async fn check_missing(args: CheckMissingArgs) {
let config: StickerConfig = let config: StickerConfig =
serde_yaml::from_reader(config_file).expect("could not parse stickers.yml"); serde_yaml::from_reader(config_file).expect("could not parse stickers.yml");
let stickers_for_sticker_sets: Vec<(String, Vec<String>)> = args let stickers_for_sticker_sets: Vec<(&String, &Vec<String>)> = args
.sticker_sets .sticker_sets
.iter() .iter()
.map(|pack_id| { .map(|pack_id| {
return ( return (pack_id, config.sticker_sets.get(pack_id).unwrap());
pack_id.clone(),
config.sticker_sets.get(pack_id).unwrap().clone(),
);
}) })
.collect(); .collect();
let missing_stickers: Vec<(String, Vec<String>)> = stickers_for_sticker_sets let missing_stickers: Vec<(&String, Vec<&String>)> = stickers_for_sticker_sets
.iter() .iter()
.map(|(sticker_set_name, sticker_set_stickers)| { .map(|(sticker_set_name, sticker_set_stickers)| {
return ( return (
sticker_set_name.clone(), *sticker_set_name,
config config
.stickers .stickers
.iter() .iter()
.filter(|all_stickers_sticker| { .filter(|all_stickers_sticker| {
!sticker_set_stickers.contains(all_stickers_sticker.0) !sticker_set_stickers.contains(all_stickers_sticker.0)
}) })
.map(|b| b.0.clone()) .map(|b| b.0)
.collect::<Vec<String>>(), .collect::<Vec<&String>>(),
); );
}) })
.collect(); .collect();
let total_missing: Vec<String> = HashMap::<String, bool>::from_iter( let total_missing: Vec<&String> = HashMap::<&String, bool>::from_iter(
missing_stickers missing_stickers
.iter() .iter()
.map(|(_pack_name, stickers)| stickers.clone()) .map(|(_pack_name, stickers)| stickers.clone())
.collect::<Vec<Vec<String>>>() .collect::<Vec<Vec<&String>>>()
.concat() .concat()
.iter() .iter()
.map(|sticker_name| (sticker_name.clone(), true)), .map(|sticker_name| (*sticker_name, true)),
) )
.into_keys() .into_keys()
.collect(); .collect();
let missing_from_all: Vec<&String> = total_missing let missing_from_all: Vec<&String> = total_missing
.iter() .clone()
.into_iter()
.filter(|missing_sticker| { .filter(|missing_sticker| {
return missing_stickers return missing_stickers
.iter() .iter()