| 1 |
use super::{ |
| 2 |
ContactId, DateTime, Event, EventId, NaiveDate, NewEvent, ProjectId, Result, TaskId, UserId, |
| 3 |
Utc, async_trait, |
| 4 |
}; |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#[async_trait] |
| 16 |
pub trait EventRepository: Send + Sync { |
| 17 |
|
| 18 |
async fn list_all(&self, user_id: UserId) -> Result<Vec<Event>>; |
| 19 |
|
| 20 |
|
| 21 |
async fn list_by_project(&self, user_id: UserId, project_id: ProjectId) -> Result<Vec<Event>>; |
| 22 |
|
| 23 |
|
| 24 |
async fn list_by_contact(&self, user_id: UserId, contact_id: ContactId) -> Result<Vec<Event>>; |
| 25 |
|
| 26 |
|
| 27 |
async fn get_by_id(&self, id: EventId, user_id: UserId) -> Result<Option<Event>>; |
| 28 |
|
| 29 |
|
| 30 |
async fn create(&self, user_id: UserId, event: NewEvent) -> Result<Event>; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
async fn restore(&self, user_id: UserId, event: &Event) -> Result<()>; |
| 37 |
|
| 38 |
|
| 39 |
async fn update( |
| 40 |
&self, |
| 41 |
id: EventId, |
| 42 |
user_id: UserId, |
| 43 |
event: crate::models::UpdateEvent, |
| 44 |
) -> Result<Option<Event>>; |
| 45 |
|
| 46 |
|
| 47 |
async fn delete(&self, id: EventId, user_id: UserId) -> Result<bool>; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
async fn set_external_ref( |
| 52 |
&self, |
| 53 |
id: EventId, |
| 54 |
user_id: UserId, |
| 55 |
source: &str, |
| 56 |
external_id: &str, |
| 57 |
) -> Result<()>; |
| 58 |
|
| 59 |
|
| 60 |
async fn delete_many(&self, ids: &[EventId], user_id: UserId) -> Result<u64>; |
| 61 |
|
| 62 |
|
| 63 |
async fn get_upcoming(&self, user_id: UserId, days: i64) -> Result<Vec<Event>>; |
| 64 |
|
| 65 |
|
| 66 |
async fn get_by_linked_task(&self, user_id: UserId, task_id: TaskId) -> Result<Option<Event>>; |
| 67 |
|
| 68 |
|
| 69 |
async fn delete_by_linked_task(&self, user_id: UserId, task_id: TaskId) -> Result<bool>; |
| 70 |
|
| 71 |
|
| 72 |
async fn list_for_date(&self, user_id: UserId, date: NaiveDate) -> Result<Vec<Event>>; |
| 73 |
|
| 74 |
|
| 75 |
async fn list_between( |
| 76 |
&self, |
| 77 |
user_id: UserId, |
| 78 |
start: DateTime<Utc>, |
| 79 |
end: DateTime<Utc>, |
| 80 |
) -> Result<Vec<Event>>; |
| 81 |
|
| 82 |
|
| 83 |
async fn list_recurring(&self, user_id: UserId) -> Result<Vec<Event>>; |
| 84 |
|
| 85 |
|
| 86 |
async fn find_by_external_id( |
| 87 |
&self, |
| 88 |
source: &str, |
| 89 |
ext_id: &str, |
| 90 |
user_id: UserId, |
| 91 |
) -> Result<Option<Event>>; |
| 92 |
|
| 93 |
|
| 94 |
async fn snooze( |
| 95 |
&self, |
| 96 |
id: EventId, |
| 97 |
user_id: UserId, |
| 98 |
until: DateTime<Utc>, |
| 99 |
) -> Result<Option<Event>>; |
| 100 |
|
| 101 |
|
| 102 |
async fn unsnooze(&self, id: EventId, user_id: UserId) -> Result<Option<Event>>; |
| 103 |
|
| 104 |
|
| 105 |
async fn list_snoozed(&self, user_id: UserId) -> Result<Vec<Event>>; |
| 106 |
} |
| 107 |
|