Temporarily update all mods to backfill fields
This commit is contained in:
parent
b97689b7fd
commit
e7b5c750cd
32
src/main.rs
32
src/main.rs
@ -271,22 +271,6 @@ pub async fn main() -> Result<()> {
|
||||
let mods_to_create_or_update: Vec<UnsavedMod> = scraped
|
||||
.mods
|
||||
.iter()
|
||||
.filter(|scraped_mod| {
|
||||
if let Some(processed_mod) = processed_mods
|
||||
.iter()
|
||||
.find(|processed_mod| processed_mod.nexus_mod_id == scraped_mod.nexus_mod_id)
|
||||
{
|
||||
if processed_mod.last_updated_files_at
|
||||
> NaiveDateTime::new(
|
||||
scraped_mod.last_update_at,
|
||||
NaiveTime::from_hms(0, 0, 0),
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
})
|
||||
.map(|scraped_mod| UnsavedMod {
|
||||
name: scraped_mod.name,
|
||||
nexus_mod_id: scraped_mod.nexus_mod_id,
|
||||
@ -310,6 +294,22 @@ pub async fn main() -> Result<()> {
|
||||
|
||||
let mods = game_mod::batched_insert(&pool, &mods_to_create_or_update).await?;
|
||||
|
||||
let mods: Vec<Mod> =
|
||||
mods.into_iter()
|
||||
.filter(|updated_mod| {
|
||||
if let Some(processed_mod) = processed_mods.iter().find(|processed_mod| {
|
||||
processed_mod.nexus_mod_id == updated_mod.nexus_mod_id
|
||||
}) {
|
||||
if let Some(last_update_at) = updated_mod.last_update_at {
|
||||
if processed_mod.last_updated_files_at > last_update_at {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
})
|
||||
.collect();
|
||||
|
||||
for db_mod in mods {
|
||||
let mod_span = info_span!("mod", name = ?&db_mod.name, id = &db_mod.nexus_mod_id);
|
||||
let _mod_span = mod_span.enter();
|
||||
|
Loading…
Reference in New Issue
Block a user