Add updated_after option to limit files generated on every run
Instead of generating files for all mods every update, only update files for mods that have been updated since the last run.
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
use anyhow::Result;
|
||||
use chrono::NaiveDateTime;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::models::file;
|
||||
|
||||
pub async fn dump_file_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str) -> Result<()> {
|
||||
pub async fn dump_file_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
||||
let page_size = 20;
|
||||
let mut last_id = None;
|
||||
loop {
|
||||
let files =
|
||||
file::batched_get_with_cells(&pool, page_size, last_id, "Skyrim.esm", 1).await?;
|
||||
file::batched_get_with_cells(&pool, page_size, last_id, "Skyrim.esm", 1, updated_after).await?;
|
||||
if files.is_empty() {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
use anyhow::Result;
|
||||
use chrono::NaiveDateTime;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::models::game_mod;
|
||||
|
||||
pub async fn dump_mod_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str) -> Result<()> {
|
||||
pub async fn dump_mod_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
||||
let page_size = 20;
|
||||
let mut last_id = None;
|
||||
loop {
|
||||
let mods =
|
||||
game_mod::batched_get_with_cells(&pool, page_size, last_id, "Skyrim.esm", 1).await?;
|
||||
game_mod::batched_get_with_cells(&pool, page_size, last_id, "Skyrim.esm", 1, updated_after).await?;
|
||||
if mods.is_empty() {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use anyhow::Result;
|
||||
use chrono::NaiveDateTime;
|
||||
use std::fs::{create_dir_all, File};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
@@ -21,12 +22,12 @@ fn format_radix(mut x: u64, radix: u32) -> String {
|
||||
result.into_iter().rev().collect()
|
||||
}
|
||||
|
||||
pub async fn dump_plugin_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str) -> Result<()> {
|
||||
pub async fn dump_plugin_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
||||
let page_size = 20;
|
||||
let mut last_hash = None;
|
||||
loop {
|
||||
let plugins =
|
||||
plugin::batched_get_by_hash_with_mods(pool, page_size, last_hash, "Skyrim.esm", 1).await?;
|
||||
plugin::batched_get_by_hash_with_mods(pool, page_size, last_hash, "Skyrim.esm", 1, updated_after).await?;
|
||||
if plugins.is_empty() {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user