initial commit
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I4a6b498153eccd5407510dd541b7f4816a6a6964
This commit is contained in:
commit
6a73d11c4b
124 changed files with 26877 additions and 0 deletions
34
crates/pinakes-server/src/routes/database.rs
Normal file
34
crates/pinakes-server/src/routes/database.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
use axum::Json;
|
||||
use axum::extract::State;
|
||||
|
||||
use crate::dto::DatabaseStatsResponse;
|
||||
use crate::error::ApiError;
|
||||
use crate::state::AppState;
|
||||
|
||||
pub async fn database_stats(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<DatabaseStatsResponse>, ApiError> {
|
||||
let stats = state.storage.database_stats().await?;
|
||||
Ok(Json(DatabaseStatsResponse {
|
||||
media_count: stats.media_count,
|
||||
tag_count: stats.tag_count,
|
||||
collection_count: stats.collection_count,
|
||||
audit_count: stats.audit_count,
|
||||
database_size_bytes: stats.database_size_bytes,
|
||||
backend_name: stats.backend_name,
|
||||
}))
|
||||
}
|
||||
|
||||
pub async fn vacuum_database(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
state.storage.vacuum().await?;
|
||||
Ok(Json(serde_json::json!({"status": "ok"})))
|
||||
}
|
||||
|
||||
pub async fn clear_database(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
state.storage.clear_all_data().await?;
|
||||
Ok(Json(serde_json::json!({"status": "ok"})))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue