intent_engine/db/
models.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use sqlx::FromRow;
4
5#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
6pub struct Task {
7 pub id: i64,
8 pub parent_id: Option<i64>,
9 pub name: String,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 pub spec: Option<String>,
12 pub status: String,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 pub complexity: Option<i32>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 pub priority: Option<i32>,
17 pub first_todo_at: Option<DateTime<Utc>>,
18 pub first_doing_at: Option<DateTime<Utc>>,
19 pub first_done_at: Option<DateTime<Utc>>,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct TaskWithEvents {
24 #[serde(flatten)]
25 pub task: Task,
26 #[serde(skip_serializing_if = "Option::is_none")]
27 pub events_summary: Option<EventsSummary>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct EventsSummary {
32 pub total_count: i64,
33 pub recent_events: Vec<Event>,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
37pub struct Event {
38 pub id: i64,
39 pub task_id: i64,
40 pub timestamp: DateTime<Utc>,
41 pub log_type: String,
42 pub discussion_data: String,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
46pub struct WorkspaceState {
47 pub key: String,
48 pub value: String,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct Report {
53 pub summary: ReportSummary,
54 #[serde(skip_serializing_if = "Option::is_none")]
55 pub tasks: Option<Vec<Task>>,
56 #[serde(skip_serializing_if = "Option::is_none")]
57 pub events: Option<Vec<Event>>,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct ReportSummary {
62 pub total_tasks: i64,
63 pub tasks_by_status: StatusBreakdown,
64 pub total_events: i64,
65 pub date_range: Option<DateRange>,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct StatusBreakdown {
70 pub todo: i64,
71 pub doing: i64,
72 pub done: i64,
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct DateRange {
77 pub from: DateTime<Utc>,
78 pub to: DateTime<Utc>,
79}