Skip to main content

recall_wire/
admin.rs

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