#45: Add list of malformed article

This commit is contained in:
mtkennerly 2024-06-22 17:05:11 -04:00
parent 374ee97baa
commit 6676218ee7
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
4 changed files with 95 additions and 1 deletions

View file

@ -1,5 +1,6 @@
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use itertools::Itertools;
use once_cell::sync::Lazy;
use regex::Regex;
use wikitext_parser::{Attribute, TextPiece};
@ -1110,6 +1111,25 @@ impl ResourceFile for WikiMetaCache {
}
}
pub fn save_malformed_list(wiki_cache: &WikiCache) {
let lines: Vec<String> = wiki_cache
.0
.iter()
.sorted_by(|(k1, _), (k2, _)| k1.to_lowercase().cmp(&k2.to_lowercase()))
.filter(|(_, v)| v.malformed)
.map(|(k, v)| format!("* [{}](https://www.pcgamingwiki.com/wiki/?curid={})", k, v.page_id))
.collect();
_ = std::fs::write(
format!("{}/data/wiki-malformed.md", crate::REPO),
if lines.is_empty() {
"* No errors found".to_string()
} else {
lines.join("\n") + "\n"
},
);
}
#[cfg(test)]
mod tests {
use super::*;