Sort Steam IDs numerically

This commit is contained in:
mtkennerly 2023-12-02 11:11:53 +08:00
parent 62a97e4d9f
commit d63f0eb485
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
3 changed files with 147436 additions and 147436 deletions

File diff suppressed because it is too large Load diff

View file

@ -134,7 +134,7 @@ impl Manifest {
let mut game = Game::default();
game.integrate_wiki(info, title);
if let Some(id) = game.steam.id {
if let Some(info) = steam_cache.0.get(id.to_string().as_str()) {
if let Some(info) = steam_cache.0.get(&id) {
game.integrate_steam(info);
}
}

View file

@ -5,7 +5,7 @@ use crate::{resource::ResourceFile, wiki::WikiCache, Error, State, REPO};
const SAVE_INTERVAL: u32 = 100;
#[derive(Debug, Default, serde::Serialize, serde::Deserialize)]
pub struct SteamCache(pub BTreeMap<String, SteamCacheEntry>);
pub struct SteamCache(pub BTreeMap<u32, SteamCacheEntry>);
impl ResourceFile for SteamCache {
const FILE_NAME: &'static str = "data/steam-game-cache.yaml";
@ -18,14 +18,14 @@ impl SteamCache {
self.0
.iter()
.filter(|(_, v)| !outdated_only || v.state == State::Outdated)
.filter_map(|(k, _)| k.parse::<u32>().ok())
.map(|(k, _)| *k)
.collect()
});
for app_id in app_ids {
let latest = SteamCacheEntry::fetch_from_id(app_id)?;
self.0.insert(
app_id.to_string(),
app_id,
latest.unwrap_or_else(|| SteamCacheEntry {
state: State::Handled,
..Default::default()
@ -47,7 +47,7 @@ impl SteamCache {
if wiki.state == State::Updated {
if let Some(id) = wiki.steam {
self.0
.entry(id.to_string())
.entry(id)
.and_modify(|x| {
x.state = State::Outdated;
})