Skip to content

Commit

Permalink
Add Store::find_checks_by_check_list_id
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 16, 2023
1 parent 2f5b32a commit 0836959
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rust/crates/web/src/infra/firestore_store.rs
Expand Up @@ -49,4 +49,11 @@ impl Store for FirestoreStore {
async fn find_all_items(&self) -> Result<Vec<model::Item>, use_case::Error> {
todo!()
}

async fn find_checks_by_check_list_id(
&self,
check_list_id: String,
) -> Result<Vec<model::Check>, use_case::Error> {
todo!()
}
}
11 changes: 11 additions & 0 deletions rust/crates/web/src/infra/store.rs
Expand Up @@ -25,6 +25,17 @@ impl Store for InMemoryStore {
async fn find_all_items(&self) -> Result<Vec<model::Item>, use_case::Error> {
Ok(self.items.clone())
}
async fn find_checks_by_check_list_id(
&self,
check_list_id: String,
) -> Result<Vec<model::Check>, use_case::Error> {
Ok(self
.checks
.iter()
.filter(|check| check.check_list_id == check_list_id)
.cloned()
.collect())
}
}

impl InMemoryStore {
Expand Down
4 changes: 4 additions & 0 deletions rust/crates/web/src/use_case.rs
Expand Up @@ -14,6 +14,10 @@ pub trait Store {
async fn find_all_check_lists(&self) -> Result<Vec<model::CheckList>, Error>;
async fn find_all_checks(&self) -> Result<Vec<model::Check>, Error>;
async fn find_all_items(&self) -> Result<Vec<model::Item>, Error>;
async fn find_checks_by_check_list_id(
&self,
check_list_id: String,
) -> Result<Vec<model::Check>, Error>;
}

pub trait HasSchema {
Expand Down

0 comments on commit 0836959

Please sign in to comment.