- Refactor database interaction for proposals and activities. - Add activity tracking for proposal creation and voting. - Improve logging for better debugging and monitoring. - Update governance views to display recent activities. - Add strum and strum_macros crates for enum handling. - Update Cargo.lock file with new dependencies.
18 lines
659 B
Rust
18 lines
659 B
Rust
use std::path::PathBuf;
|
|
|
|
use heromodels::db::hero::OurDB;
|
|
|
|
/// The path to the database file. Change this as needed for your environment.
|
|
pub const DB_PATH: &str = "/tmp/freezone_db";
|
|
|
|
/// Returns a shared OurDB instance for the given path. You can wrap this in Arc/Mutex for concurrent access if needed.
|
|
pub fn get_db() -> Result<OurDB, String> {
|
|
let db_path = PathBuf::from(DB_PATH);
|
|
if let Some(parent) = db_path.parent() {
|
|
let _ = std::fs::create_dir_all(parent);
|
|
}
|
|
// Temporarily reset the database to fix the serialization issue
|
|
let db = heromodels::db::hero::OurDB::new(db_path, false).expect("Can create DB");
|
|
Ok(db)
|
|
}
|