mirror of
				https://github.com/csehviktor/status-monitor.git
				synced 2025-08-08 18:06:14 +02:00 
			
		
		
		
	cleanup code
This commit is contained in:
		| @@ -4,7 +4,7 @@ use tokio::sync::Mutex; | ||||
| use std::path::Path; | ||||
| use chrono::{DateTime, Utc}; | ||||
|  | ||||
| use super::{StorageRepository, UptimeMessage, UptimeModel}; | ||||
| use super::{StorageRepository, UptimeMessage, UptimeStorageModel}; | ||||
|  | ||||
| pub struct SQLiteRepository { | ||||
|     conn: Mutex<Connection> | ||||
| @@ -40,7 +40,7 @@ impl SQLiteRepository { | ||||
|  | ||||
| #[async_trait] | ||||
| impl StorageRepository for SQLiteRepository { | ||||
|     async fn record_message(&self, agent: &str) -> anyhow::Result<()> { | ||||
|     async fn record_uptime(&self, agent: &str) -> anyhow::Result<()> { | ||||
|         let conn = self.conn.lock().await; | ||||
|         let now = Utc::now().to_rfc3339(); | ||||
|  | ||||
| @@ -64,7 +64,7 @@ impl StorageRepository for SQLiteRepository { | ||||
|             let first_seen: DateTime<Utc> = row.get::<_, String>(1)?.parse().unwrap(); | ||||
|             let last_seen: DateTime<Utc> = row.get::<_, String>(2)?.parse().unwrap(); | ||||
|  | ||||
|             Ok(UptimeModel { | ||||
|             Ok(UptimeStorageModel { | ||||
|                 id: row.get(0)?, | ||||
|                 first_seen, | ||||
|                 last_seen, | ||||
| @@ -72,7 +72,7 @@ impl StorageRepository for SQLiteRepository { | ||||
|             }) | ||||
|         })?; | ||||
|  | ||||
|         let models: Result<Vec<UptimeModel>, _> = result.collect(); | ||||
|         let models: Result<Vec<UptimeStorageModel>, _> = result.collect(); | ||||
|  | ||||
|         Ok(models?.into_iter().map(Into::into).collect()) | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user