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