koprogo_api/application/ports/
vote_repository.rs1use crate::domain::entities::Vote;
2use async_trait::async_trait;
3use uuid::Uuid;
4
5#[async_trait]
7pub trait VoteRepository: Send + Sync {
8 async fn create(&self, vote: &Vote) -> Result<Vote, String>;
10
11 async fn find_by_id(&self, id: Uuid) -> Result<Option<Vote>, String>;
13
14 async fn find_by_resolution_id(&self, resolution_id: Uuid) -> Result<Vec<Vote>, String>;
16
17 async fn find_by_owner_id(&self, owner_id: Uuid) -> Result<Vec<Vote>, String>;
19
20 async fn find_by_resolution_and_unit(
22 &self,
23 resolution_id: Uuid,
24 unit_id: Uuid,
25 ) -> Result<Option<Vote>, String>;
26
27 async fn has_voted(&self, resolution_id: Uuid, unit_id: Uuid) -> Result<bool, String>;
29
30 async fn update(&self, vote: &Vote) -> Result<Vote, String>;
32
33 async fn delete(&self, id: Uuid) -> Result<bool, String>;
35
36 async fn count_by_resolution_and_choice(
38 &self,
39 resolution_id: Uuid,
40 ) -> Result<(i32, i32, i32), String>; async fn sum_voting_power_by_resolution(
44 &self,
45 resolution_id: Uuid,
46 ) -> Result<(f64, f64, f64), String>; }