feat: add teacher_id filter to student daka query
Allow students to filter dakas by teacher_id when querying. Both student_id and teacher_id can now coexist in the request. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -831,8 +831,9 @@ pub async fn raw_find_dakas_with_sections_by_user_id(
|
||||
debug!("raw_find_dakas_with_sections_by_user_id -> teacher_id: {:?} / student_id: {:?} / scope: {:?}", teacher_id, student_id, scope);
|
||||
let current_org_id = required_current_org_id_from_sudoer_token_str(&_root.0)?;
|
||||
|
||||
if (teacher_id.is_some() && student_id.is_some())
|
||||
|| (teacher_id.is_none() && student_id.is_none())
|
||||
// student_id and teacher_id can coexist (student filtering by teacher)
|
||||
// but at least one must be present
|
||||
if teacher_id.is_none() && student_id.is_none()
|
||||
{
|
||||
return Err(anyhow!(HtyErr {
|
||||
code: HtyErrCode::WebErr,
|
||||
@@ -898,7 +899,7 @@ pub async fn raw_find_dakas_with_sections_by_user_id(
|
||||
|
||||
dakas = dakas_with_pages.0;
|
||||
} else {
|
||||
// student_id
|
||||
// student_id (with optional teacher_id filter)
|
||||
let id_student = student_id
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("student_id is required"))?;
|
||||
@@ -908,6 +909,7 @@ pub async fn raw_find_dakas_with_sections_by_user_id(
|
||||
¤t_org_id,
|
||||
page,
|
||||
page_size,
|
||||
*teacher_id,
|
||||
extract_conn(fetch_db_conn(&db_pool)?).deref_mut(),
|
||||
)?;
|
||||
dakas = dakas_with_pages.0;
|
||||
|
||||
Reference in New Issue
Block a user