Scope bulk_get_last_updated_by_nexus_mod_ids by game_id

Was accidentally skipping a ton of skyrim mods because of this.
This commit is contained in:
Tyler Hallada 2022-09-26 00:00:22 -04:00
parent c3264b3b11
commit 203af0adc9
3 changed files with 6 additions and 1 deletions

View File

@ -53,6 +53,7 @@ pub async fn update(
has_next_page = scraped.has_next_page; has_next_page = scraped.has_next_page;
let processed_mods = game_mod::bulk_get_last_updated_by_nexus_mod_ids( let processed_mods = game_mod::bulk_get_last_updated_by_nexus_mod_ids(
&pool, &pool,
game.id,
&scraped &scraped
.mods .mods
.iter() .iter()

View File

@ -122,12 +122,15 @@ pub struct ModLastUpdatedFilesAt {
#[instrument(level = "debug", skip(pool))] #[instrument(level = "debug", skip(pool))]
pub async fn bulk_get_last_updated_by_nexus_mod_ids( pub async fn bulk_get_last_updated_by_nexus_mod_ids(
pool: &sqlx::Pool<sqlx::Postgres>, pool: &sqlx::Pool<sqlx::Postgres>,
game_id: i32,
nexus_mod_ids: &[i32], nexus_mod_ids: &[i32],
) -> Result<Vec<ModLastUpdatedFilesAt>> { ) -> Result<Vec<ModLastUpdatedFilesAt>> {
sqlx::query!( sqlx::query!(
"SELECT nexus_mod_id, last_updated_files_at FROM mods "SELECT nexus_mod_id, last_updated_files_at FROM mods
WHERE nexus_mod_id = ANY($1::int[]) WHERE game_id = $1
AND nexus_mod_id = ANY($2::int[])
AND last_updated_files_at IS NOT NULL", AND last_updated_files_at IS NOT NULL",
game_id,
nexus_mod_ids, nexus_mod_ids,
) )
.map(|row| ModLastUpdatedFilesAt { .map(|row| ModLastUpdatedFilesAt {

View File

@ -8,6 +8,7 @@ pub struct ModListResponse {
html: Html, html: Html,
} }
#[derive(Debug)]
pub struct ScrapedMod<'a> { pub struct ScrapedMod<'a> {
pub nexus_mod_id: i32, pub nexus_mod_id: i32,
pub name: &'a str, pub name: &'a str,