| 1 |
use super::{ |
| 2 |
DateTime, NewProblem, Problem, ProblemId, ProblemStatus, ProjectId, Result, TaskId, UserId, |
| 3 |
Utc, async_trait, |
| 4 |
}; |
| 5 |
|
| 6 |
|
| 7 |
#[derive(Debug, Clone, Default)] |
| 8 |
pub struct ProblemFilter { |
| 9 |
|
| 10 |
pub source: Option<String>, |
| 11 |
|
| 12 |
pub status: Option<ProblemStatus>, |
| 13 |
|
| 14 |
pub project_id: Option<ProjectId>, |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#[async_trait] |
| 26 |
pub trait ProblemRepository: Send + Sync { |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
async fn list(&self, user_id: UserId, filter: &ProblemFilter) -> Result<Vec<Problem>>; |
| 33 |
|
| 34 |
|
| 35 |
async fn get_by_id(&self, id: ProblemId, user_id: UserId) -> Result<Option<Problem>>; |
| 36 |
|
| 37 |
|
| 38 |
async fn find_by_source_ref( |
| 39 |
&self, |
| 40 |
user_id: UserId, |
| 41 |
source: &str, |
| 42 |
source_ref: &str, |
| 43 |
) -> Result<Option<Problem>>; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
async fn ingest(&self, user_id: UserId, problem: NewProblem) -> Result<Problem>; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
async fn promote( |
| 60 |
&self, |
| 61 |
id: ProblemId, |
| 62 |
user_id: UserId, |
| 63 |
task_id: TaskId, |
| 64 |
) -> Result<Option<Problem>>; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
async fn set_status( |
| 70 |
&self, |
| 71 |
id: ProblemId, |
| 72 |
user_id: UserId, |
| 73 |
status: ProblemStatus, |
| 74 |
) -> Result<Option<Problem>>; |
| 75 |
|
| 76 |
|
| 77 |
async fn set_project( |
| 78 |
&self, |
| 79 |
id: ProblemId, |
| 80 |
user_id: UserId, |
| 81 |
project_id: Option<ProjectId>, |
| 82 |
) -> Result<Option<Problem>>; |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
async fn delete(&self, id: ProblemId, user_id: UserId) -> Result<bool>; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
async fn last_pulled_at(&self, user_id: UserId, source: &str) -> Result<Option<DateTime<Utc>>>; |
| 93 |
} |
| 94 |
|