recall_wire/admin.rs
1//! `GET /admin/stats` — what the owner is storing, per project.
2//!
3//! For `RECALL_TOKEN` or an admin device, and read-only: there is no admin *write*
4//! surface for memory, deliberately. Managing devices is in [`crate::devices`],
5//! and touches no memory.
6
7use serde::{Deserialize, Serialize};
8
9/// One project's row in [`AdminStats`].
10#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
11pub struct ProjectStats {
12 /// The key the project syncs under.
13 pub project_key: String,
14 /// Live files, tombstones excluded.
15 pub file_count: i64,
16 /// Tombstoned files, which still hold their last known content.
17 pub deleted_count: i64,
18 /// Every machine that has written to this project.
19 pub sources: Vec<String>,
20 /// The newest `updated_at` across the project's files.
21 pub last_updated_at: String,
22}
23
24/// The aggregate line of [`AdminStats`].
25#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
26pub struct AdminTotals {
27 /// How many projects have ever synced.
28 pub project_count: i64,
29 /// Live files across every project.
30 pub file_count: i64,
31 /// Tombstones across every project.
32 pub deleted_count: i64,
33}
34
35/// Body returned by `GET /admin/stats`.
36#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
37pub struct AdminStats {
38 /// One row per project, newest activity first.
39 pub projects: Vec<ProjectStats>,
40 /// The same numbers, summed.
41 pub totals: AdminTotals,
42 /// The commit the running binary was built from.
43 pub git_commit: String,
44 /// When the database was last backed up.
45 #[serde(default, skip_serializing_if = "String::is_empty")]
46 pub last_backup_at: String,
47}