Skip to main content

max / goingson

3.5 KB · 115 lines History Blame Raw
1 use super::{NaiveDate, Result, UserId, async_trait};
2
3 /// Repository for weekly review tracking.
4 #[async_trait]
5 pub trait WeeklyReviewRepository: Send + Sync {
6 /// Gets the weekly review for a specific week.
7 async fn get_for_week(
8 &self,
9 user_id: UserId,
10 week_start: NaiveDate,
11 ) -> Result<Option<crate::models::WeeklyReview>>;
12
13 /// Creates or updates a weekly review.
14 async fn upsert(
15 &self,
16 user_id: UserId,
17 week_start: NaiveDate,
18 notes: &str,
19 ) -> Result<crate::models::WeeklyReview>;
20
21 /// Lists every weekly review for a user across all weeks (for full backup export).
22 async fn list_all(&self, user_id: UserId) -> Result<Vec<crate::models::WeeklyReview>>;
23
24 /// Checks if the current week's review is completed.
25 async fn is_current_week_completed(&self, user_id: UserId) -> Result<bool>;
26
27 /// Sets vacation days for a specific week.
28 async fn set_vacation_days(
29 &self,
30 user_id: UserId,
31 week_start: NaiveDate,
32 days: &[u8],
33 ) -> Result<()>;
34 }
35
36 /// Repository for daily review notes.
37 #[async_trait]
38 pub trait DailyNoteRepository: Send + Sync {
39 /// Gets the daily note for a specific date.
40 async fn get_by_date(
41 &self,
42 user_id: UserId,
43 date: NaiveDate,
44 ) -> Result<Option<crate::models::DailyNote>>;
45
46 /// Creates or updates a daily note (upsert by user_id + date).
47 async fn upsert(
48 &self,
49 user_id: UserId,
50 date: NaiveDate,
51 went_well: &str,
52 could_improve: &str,
53 is_reviewed: bool,
54 ) -> Result<crate::models::DailyNote>;
55
56 /// Lists every daily note for a user (for full backup export).
57 async fn list_all(&self, user_id: UserId) -> Result<Vec<crate::models::DailyNote>>;
58 }
59
60 /// Repository for monthly review goals and reflections.
61 #[async_trait]
62 pub trait MonthlyReviewRepository: Send + Sync {
63 /// Gets all goals for a specific month.
64 async fn list_goals(
65 &self,
66 user_id: UserId,
67 month: &str,
68 ) -> Result<Vec<crate::models::MonthlyGoal>>;
69
70 /// Lists every goal for a user across all months (for full backup export).
71 async fn list_all_goals(&self, user_id: UserId) -> Result<Vec<crate::models::MonthlyGoal>>;
72
73 /// Lists every reflection for a user across all months (for full backup export).
74 async fn list_all_reflections(
75 &self,
76 user_id: UserId,
77 ) -> Result<Vec<crate::models::MonthlyReflection>>;
78
79 /// Creates or updates a goal for a month at a given position (1-3).
80 async fn upsert_goal(
81 &self,
82 user_id: UserId,
83 month: &str,
84 text: &str,
85 position: i32,
86 ) -> Result<crate::models::MonthlyGoal>;
87
88 /// Updates the status of a goal.
89 async fn update_goal_status(
90 &self,
91 id: crate::MonthlyGoalId,
92 user_id: UserId,
93 status: &crate::models::MonthlyGoalStatus,
94 ) -> Result<Option<crate::models::MonthlyGoal>>;
95
96 /// Deletes a goal.
97 async fn delete_goal(&self, id: crate::MonthlyGoalId, user_id: UserId) -> Result<bool>;
98
99 /// Gets the reflection for a specific month.
100 async fn get_reflection(
101 &self,
102 user_id: UserId,
103 month: &str,
104 ) -> Result<Option<crate::models::MonthlyReflection>>;
105
106 /// Creates or updates the reflection for a month.
107 async fn upsert_reflection(
108 &self,
109 user_id: UserId,
110 month: &str,
111 highlight: &str,
112 change: &str,
113 ) -> Result<crate::models::MonthlyReflection>;
114 }
115