Skip to content

Commit ee1c92c

Browse files
Committee session status change providers (#2822)
Co-authored-by: stacktraceghost <stacktraceghost@users.noreply.github.com>
1 parent e829e39 commit ee1c92c

10 files changed

+391
-823
lines changed

backend/.sqlx/query-3b49ad9988a84a1a738cfd9e3449ad873624f5e70f32f8379f475e43f6d41874.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/.sqlx/query-581c25f1e5db5e0ee35f7fdb0fed0d21988dc6118bfe8a179e24361b5373af80.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/src/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ pub mod election;
77
pub mod investigation;
88
pub mod middleware;
99
pub mod polling_station;
10+
pub mod providers;
1011
pub mod report;
1112
pub mod user;

backend/src/api/providers.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use sqlx::SqliteConnection;
2+
3+
use crate::{
4+
api::committee_session::CommitteeSessionError,
5+
domain::{
6+
committee_session::CommitteeSessionId,
7+
committee_session_status::{
8+
CommitteeSessionHasInvestigationsProvider, CommitteeSessionHasPollingStationsProvider,
9+
DataEntryCompleteResultsProvider,
10+
},
11+
},
12+
repository::{data_entry_repo, investigation_repo, polling_station_repo},
13+
};
14+
15+
impl CommitteeSessionHasPollingStationsProvider for SqliteConnection {
16+
async fn has_polling_stations(
17+
&mut self,
18+
committee_session_id: CommitteeSessionId,
19+
) -> Result<bool, CommitteeSessionError> {
20+
Ok(polling_station_repo::has_any(self, committee_session_id).await?)
21+
}
22+
}
23+
24+
impl CommitteeSessionHasInvestigationsProvider for SqliteConnection {
25+
async fn has_investigations(
26+
&mut self,
27+
committee_session_id: CommitteeSessionId,
28+
) -> Result<bool, CommitteeSessionError> {
29+
Ok(
30+
investigation_repo::has_investigations_for_committee_session(
31+
self,
32+
committee_session_id,
33+
)
34+
.await?,
35+
)
36+
}
37+
}
38+
39+
impl DataEntryCompleteResultsProvider for SqliteConnection {
40+
async fn has_complete_results(
41+
&mut self,
42+
committee_session_id: CommitteeSessionId,
43+
) -> Result<bool, CommitteeSessionError> {
44+
Ok(
45+
data_entry_repo::are_results_complete_for_committee_session(self, committee_session_id)
46+
.await?,
47+
)
48+
}
49+
}

backend/src/domain/committee_session.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,29 @@ impl CommitteeSession {
4545
pub fn is_next_session(&self) -> bool {
4646
self.number > 1
4747
}
48+
49+
#[cfg(test)]
50+
pub fn first_session() -> Self {
51+
CommitteeSession {
52+
number: 1,
53+
id: CommitteeSessionId::from(0),
54+
election_id: ElectionId::from(0),
55+
location: "".to_string(),
56+
start_date_time: None,
57+
status: CommitteeSessionStatus::Created,
58+
results_eml: None,
59+
results_pdf: None,
60+
overview_pdf: None,
61+
}
62+
}
63+
64+
#[cfg(test)]
65+
pub fn next_session() -> Self {
66+
CommitteeSession {
67+
number: 2,
68+
..CommitteeSession::first_session()
69+
}
70+
}
4871
}
4972

5073
impl From<CommitteeSession> for audit_log::CommitteeSessionDetails {

0 commit comments

Comments
 (0)