Skip to content

Commit 8347fe8

Browse files
committedFeb 25, 2025
use new find_by for coaching_relationships
This function is not currently being used
1 parent 2dc5811 commit 8347fe8

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed
 

‎domain/src/coaching_relationship.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1+
use crate::coaching_relationships::Model;
2+
use crate::error::Error;
3+
use entity_api::IntoQueryFilterMap;
4+
use entity_api::{coaching_relationships, query};
5+
use sea_orm::DatabaseConnection;
6+
17
pub use entity_api::coaching_relationship::{
2-
create, find_by, find_by_id, find_by_organization_with_user_names, find_by_user,
8+
create, find_by_id, find_by_organization_with_user_names, find_by_user,
39
get_relationship_with_user_names, CoachingRelationshipWithUserNames,
410
};
11+
12+
pub async fn find_by(
13+
db: &DatabaseConnection,
14+
params: impl IntoQueryFilterMap,
15+
) -> Result<Vec<Model>, Error> {
16+
let coaching_relationships = query::find_by::<
17+
coaching_relationships::Entity,
18+
coaching_relationships::Column,
19+
>(db, params.into_query_filter_map())
20+
.await?;
21+
22+
Ok(coaching_relationships)
23+
}

‎entity_api/src/coaching_relationship.rs

-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use super::error::{EntityApiErrorKind, Error};
2-
use crate::uuid_parse_str;
32
use chrono::Utc;
43
use entity::{
54
coachees, coaches,
@@ -143,29 +142,6 @@ pub async fn get_relationship_with_user_names(
143142
Ok(query.one(db).await?)
144143
}
145144

146-
pub async fn find_by(
147-
db: &DatabaseConnection,
148-
params: std::collections::HashMap<String, String>,
149-
) -> Result<Vec<Model>, Error> {
150-
let mut query = coaching_relationships::Entity::find();
151-
152-
for (key, value) in params.iter() {
153-
match key.as_str() {
154-
"organization_id" => {
155-
query = by_organization(query, uuid_parse_str(value)?).await;
156-
}
157-
_ => {
158-
return Err(Error {
159-
source: None,
160-
error_kind: EntityApiErrorKind::InvalidQueryTerm,
161-
});
162-
}
163-
}
164-
}
165-
166-
Ok(query.all(db).await?)
167-
}
168-
169145
pub async fn by_coaching_relationship(
170146
query: Select<coaching_relationships::Entity>,
171147
id: Id,

0 commit comments

Comments
 (0)