Skip to main content

max / makenotwork

4.1 KB · 145 lines History Blame Raw
1 //! Templates for the platform-health status page (`/health`).
2
3 use std::sync::Arc;
4
5 use askama::Template;
6
7 use crate::auth::SessionUser;
8
9 use super::super::CsrfTokenOption;
10
11 /// Test result for health page display.
12 #[derive(Clone)]
13 pub struct HealthTest {
14 pub name: String,
15 pub passed: bool,
16 pub latency_ms: u64,
17 }
18
19 /// Pre-formatted health snapshot for template rendering.
20 #[derive(Clone)]
21 pub struct PrivacyJobDisplay {
22 pub name: String,
23 pub description: String,
24 pub last_ran: String,
25 pub rows_affected: String,
26 pub status_class: String,
27 }
28
29 /// Pre-formatted health check snapshot for template rendering.
30 pub struct HealthSnapshotDisplay {
31 pub checked_at: String,
32 pub status: String,
33 pub status_class: String,
34 pub duration_ms: i32,
35 }
36
37 /// Pre-formatted PoM snapshot for template rendering.
38 #[derive(Clone)]
39 pub struct PomSnapshotDisplay {
40 pub checked_at: String,
41 pub status: String,
42 pub status_class: String,
43 pub response_time_ms: i64,
44 }
45
46 /// Pre-formatted PoM incident for template rendering.
47 #[derive(Clone)]
48 pub struct PomIncidentDisplay {
49 pub to_status: String,
50 pub started_at: String,
51 pub duration: String,
52 }
53
54 /// Public page: platform health status and monitoring dashboard.
55 #[derive(Template)]
56 #[template(path = "pages/health.html")]
57 pub struct HealthTemplate {
58 pub csrf_token: CsrfTokenOption,
59 pub session_user: Option<SessionUser>,
60 // Overall status
61 pub overall_status: String,
62 pub overall_status_class: String,
63 pub uptime: String,
64 pub version: String,
65 pub check_duration_ms: u64,
66 // Database
67 pub db_status: String,
68 pub db_status_class: String,
69 pub db_pool_size: String,
70 pub db_pool_max: String,
71 pub db_pool_utilization: String,
72 pub db_active_connections: String,
73 pub user_count: String,
74 pub project_count: String,
75 pub item_count: String,
76 pub transaction_count: String,
77 pub blog_post_count: String,
78 // Sessions
79 pub session_status: String,
80 pub session_status_class: String,
81 pub active_sessions: String,
82 // Storage
83 pub storage_status: String,
84 pub storage_status_class: String,
85 pub storage_configured: bool,
86 pub storage_bucket: String,
87 pub storage_region: String,
88 // Stripe
89 pub stripe_status: String,
90 pub stripe_status_class: String,
91 pub stripe_configured: bool,
92 pub stripe_mode: String,
93 pub connected_creators: String,
94 // Email
95 pub email_status: String,
96 pub email_status_class: String,
97 pub email_provider: String,
98 // SyncKit
99 pub synckit_status: String,
100 pub synckit_status_class: String,
101 pub synckit_configured: bool,
102 pub synckit_app_count: String,
103 pub synckit_device_count: String,
104 pub synckit_log_entries: String,
105 // Security & Monitoring
106 pub admin_status: String,
107 // Background monitor
108 pub monitor_enabled: bool,
109 pub monitor_interval_secs: u64,
110 pub alerts_configured: bool,
111 pub uptime_24h: Option<String>,
112 pub uptime_7d: Option<String>,
113 pub last_incident: Option<String>,
114 pub recent_snapshots: Vec<HealthSnapshotDisplay>,
115 // Server
116 pub environment: String,
117 pub host: Arc<str>,
118 pub started_at: String,
119 // Privacy & Compliance
120 pub privacy_jobs: Vec<PrivacyJobDisplay>,
121 // Tests
122 pub public_tests: Vec<HealthTest>,
123 pub db_tests: Vec<HealthTest>,
124 pub generated_at: String,
125 // External monitoring (PoM)
126 pub pom_available: bool,
127 pub pom_status: Option<String>,
128 pub pom_status_class: Option<String>,
129 pub pom_response_time_ms: Option<i64>,
130 pub pom_checked_at: Option<String>,
131 pub pom_uptime_24h: Option<String>,
132 pub pom_uptime_7d: Option<String>,
133 pub pom_recent: Vec<PomSnapshotDisplay>,
134 pub pom_avg_latency: Option<String>,
135 pub pom_p95_latency: Option<String>,
136 pub pom_incident_active: bool,
137 pub pom_incident_status: Option<String>,
138 pub pom_incident_since: Option<String>,
139 pub pom_recent_incidents: Vec<PomIncidentDisplay>,
140 // External monitoring (PoM) — route checks
141 pub pom_routes_total: usize,
142 pub pom_routes_ok: usize,
143 pub pom_routes_failed: Vec<String>,
144 }
145