Filter out secondary IDs that also appear as primary IDs

This commit is contained in:
mtkennerly 2024-05-20 21:03:35 -04:00
parent 6b03d46b67
commit e0d2092c5e
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
3 changed files with 39 additions and 95 deletions

View file

@ -1,4 +1,4 @@
use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use once_cell::sync::Lazy;
use regex::Regex;
@ -92,6 +92,12 @@ async fn is_game_article(query: &str) -> Result<bool, Error> {
Ok(false)
}
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct PrimaryIds {
pub steam: HashSet<u32>,
pub gog: HashSet<u64>,
}
impl WikiCache {
pub async fn flag_recent_changes(&mut self, meta: &mut WikiMetaCache) -> Result<(), Error> {
struct RecentChange {
@ -379,6 +385,21 @@ impl WikiCache {
Ok(())
}
pub fn primary_ids(&self) -> PrimaryIds {
let mut out = PrimaryIds::default();
for info in self.0.values() {
if let Some(id) = info.steam {
out.steam.insert(id);
}
if let Some(id) = info.gog {
out.gog.insert(id);
}
}
out
}
}
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]