Add dump_games command
So the frontend can map game db ids to nexus names.
This commit is contained in:
14
src/commands/dump_games.rs
Normal file
14
src/commands/dump_games.rs
Normal 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(());
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user