Add dump_games command

So the frontend can map game db ids to nexus names.
This commit is contained in:
2022-09-03 00:31:49 -04:00
parent 7d229ccd1a
commit 782f7a473f
6 changed files with 41 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
use anyhow::Result;
use std::fs::File;
use std::io::Write;
use tracing::info;
use crate::models::game;
pub async fn dump_games(pool: &sqlx::Pool<sqlx::Postgres>, path: &str) -> Result<()> {
let games = game::get_all(&pool).await?;
info!("writing {} games to {}", games.len(), path);
let mut file = File::create(path)?;
write!(file, "{}", serde_json::to_string(&games)?)?;
return Ok(());
}

View File

@@ -7,6 +7,7 @@ pub mod dump_mod_data;
pub mod dump_mod_search_index;
pub mod dump_plugin_data;
pub mod dump_file_data;
pub mod dump_games;
pub mod update;
pub use download_tiles::download_tiles;
@@ -17,4 +18,5 @@ pub use dump_mod_data::dump_mod_data;
pub use dump_mod_search_index::dump_mod_search_index;
pub use dump_plugin_data::dump_plugin_data;
pub use dump_file_data::dump_file_data;
pub use dump_games::dump_games;
pub use update::update;