Limit cells in mod files to Skyrim worldspace cells

This commit is contained in:
Tyler Hallada 2022-02-06 23:11:03 -05:00
parent 240349cf1a
commit 891dbd791a
2 changed files with 7 additions and 2 deletions

View File

@ -256,7 +256,8 @@ pub async fn main() -> Result<()> {
let page_size = 20;
let mut last_id = None;
loop {
let mods = game_mod::batched_get_with_cells(&pool, page_size, last_id).await?;
let mods = game_mod::batched_get_with_cells(&pool, page_size, last_id, "Skyrim.esm", 1)
.await?;
if mods.is_empty() {
break;
}

View File

@ -355,6 +355,8 @@ pub async fn batched_get_with_cells(
pool: &sqlx::Pool<sqlx::Postgres>,
page_size: i64,
last_id: Option<i32>,
master: &str,
world_id: i32,
) -> Result<Vec<ModWithCells>> {
let last_id = last_id.unwrap_or(0);
sqlx::query_as!(
@ -365,12 +367,14 @@ pub async fn batched_get_with_cells(
FROM mods
LEFT OUTER JOIN plugin_cells ON plugin_cells.mod_id = mods.id
LEFT OUTER JOIN cells ON cells.id = plugin_cells.cell_id
WHERE mods.id > $2
WHERE mods.id > $2 AND cells.master = $3 AND cells.world_id = $4
GROUP BY mods.id
ORDER BY mods.id ASC
LIMIT $1",
page_size,
last_id,
master,
world_id
)
.fetch_all(pool)
.await