| 1 |
use super::{DateTime, Result, UserId, Utc, async_trait}; |
| 2 |
|
| 3 |
|
| 4 |
#[derive(Debug, Clone, serde::Serialize)] |
| 5 |
pub struct DashboardStats { |
| 6 |
|
| 7 |
pub tasks_due_today: i64, |
| 8 |
|
| 9 |
pub tasks_due_this_week: i64, |
| 10 |
|
| 11 |
pub overdue_count: i64, |
| 12 |
|
| 13 |
pub unread_emails: i64, |
| 14 |
|
| 15 |
pub upcoming_events: i64, |
| 16 |
|
| 17 |
pub active_projects: i64, |
| 18 |
|
| 19 |
pub high_urgency_tasks: Vec<HighUrgencyTask>, |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
#[derive(Debug, Clone, serde::Serialize)] |
| 24 |
pub struct HighUrgencyTask { |
| 25 |
|
| 26 |
pub id: String, |
| 27 |
|
| 28 |
pub description: String, |
| 29 |
|
| 30 |
pub urgency: f64, |
| 31 |
|
| 32 |
pub status: String, |
| 33 |
|
| 34 |
pub due: Option<String>, |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
#[async_trait] |
| 39 |
pub trait StatsRepository: Send + Sync { |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
async fn get_dashboard_stats( |
| 47 |
&self, |
| 48 |
user_id: UserId, |
| 49 |
now: DateTime<Utc>, |
| 50 |
today_start: DateTime<Utc>, |
| 51 |
tomorrow_start: DateTime<Utc>, |
| 52 |
week_end: DateTime<Utc>, |
| 53 |
) -> Result<DashboardStats>; |
| 54 |
} |
| 55 |
|