refactor: Replace surrealdb_helpers with integrated query builder methods for improved clarity and functionality

This commit is contained in:
MythEclipse
2025-09-22 16:38:07 +07:00
parent 8cdbca24ba
commit ba46a19a5a
4 changed files with 30 additions and 103 deletions
+7 -3
View File
@@ -188,8 +188,12 @@ impl<'a> TeamsRepository<'a> {
let now = Instant::now();
let db = &self.state.surrealdb_ws;
let condition = format!("{} AND is_active = true", build_thing_condition("team_id", team_id));
let sql = format!("SELECT * FROM {} WHERE {}", ResourceEnum::TeamMembers, condition);
let builder = DetailQueryBuilder::new(ResourceEnum::TeamMembers.to_string())
.with_thing_equals("team_id", team_id)
.with_condition("is_active = true")
.with_select_fields(vec!["*"]);
let sql = builder.build();
let mut result = db.query(sql).await?;
let members: Vec<TeamMembersQueryDto> = match result.take(0) {
@@ -248,7 +252,7 @@ impl<'a> TeamsRepository<'a> {
let member_count = execute_safe_count_query(
db,
&ResourceEnum::TeamMembers.to_string(),
ResourceEnum::TeamMembers.to_string(),
&conditions,
).await.unwrap_or(0);