Simplify backup timestamp display with raw TOML format and remove spacing
All checks were successful
Build and Release / build-and-release (push) Successful in 1m41s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m41s
Replace timestamp parsing with direct display of start_time from backup TOML file to ensure timestamp always appears regardless of format. Remove empty line spacing above backup section for compact layout. Changes: - Remove parsed timestamp fields and use raw start_time string from TOML - Display backup time directly from TOML file without parsing - Remove blank line above backup section for tighter layout - Simplify BackupData structure by removing last_run and next_scheduled fields Version bump to v0.1.150
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use async_trait::async_trait;
|
||||
use chrono;
|
||||
use chrono::{NaiveDateTime, DateTime};
|
||||
use cm_dashboard_shared::{AgentData, BackupData, BackupDiskData};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
@@ -47,15 +47,7 @@ impl BackupCollector {
|
||||
/// Convert BackupStatusToml to BackupData and populate AgentData
|
||||
async fn populate_backup_data(&self, agent_data: &mut AgentData) -> Result<(), CollectorError> {
|
||||
if let Some(backup_status) = self.read_backup_status().await? {
|
||||
// Parse start_time to get last_run timestamp
|
||||
let last_run = if let Ok(parsed_time) = chrono::DateTime::parse_from_str(&backup_status.start_time, "%Y-%m-%d %H:%M:%S UTC") {
|
||||
Some(parsed_time.timestamp() as u64)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Calculate next_scheduled (if needed - may need to be provided by backup script)
|
||||
let next_scheduled = None; // TODO: Extract from backup script if available
|
||||
// Use raw start_time string from TOML
|
||||
|
||||
// Extract disk information
|
||||
let repository_disk = if let Some(disk_space) = &backup_status.disk_space {
|
||||
@@ -89,12 +81,11 @@ impl BackupCollector {
|
||||
|
||||
let backup_data = BackupData {
|
||||
status: backup_status.status,
|
||||
last_run,
|
||||
next_scheduled,
|
||||
total_size_gb: Some(total_size_gb),
|
||||
repository_health: Some("ok".to_string()), // Derive from status if needed
|
||||
repository_disk,
|
||||
last_backup_size_gb: None, // Not available in current TOML format
|
||||
start_time_raw: Some(backup_status.start_time),
|
||||
};
|
||||
|
||||
agent_data.backup = backup_data;
|
||||
@@ -102,12 +93,11 @@ impl BackupCollector {
|
||||
// No backup status available - set default values
|
||||
agent_data.backup = BackupData {
|
||||
status: "unavailable".to_string(),
|
||||
last_run: None,
|
||||
next_scheduled: None,
|
||||
total_size_gb: None,
|
||||
repository_health: None,
|
||||
repository_disk: None,
|
||||
last_backup_size_gb: None,
|
||||
start_time_raw: None,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user