Filter out secondary IDs that also appear as primary IDs
This commit is contained in:
parent
6b03d46b67
commit
e0d2092c5e
3 changed files with 39 additions and 95 deletions
23
src/wiki.rs
23
src/wiki.rs
|
@ -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)]
|
||||
|
|
Reference in a new issue