fix: public-packages should only return published course packages

Add `published_at IS NOT NULL` filter to the public-packages query.
Unpublished packages (ACTIVE status but no published_at) should not
appear in the student-facing store.

Two new model methods added:
- find_all_published_by_org_with_page
- find_all_published_with_page

Existing find_all_active_* methods unchanged for admin use.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 16:07:44 +08:00
parent 541814307c
commit f534230af7
2 changed files with 79 additions and 2 deletions
+2 -2
View File
@@ -235,8 +235,8 @@ pub async fn find_public_course_packages(
let page_size = get_some_from_query_params::<i64>("page_size", &params).unwrap_or(20);
let keyword = get_some_from_query_params::<String>("keyword", &params);
match params.get("org_id") {
Some(org_id) => CoursePackage::find_all_active_by_org_with_page(org_id, &keyword, page, page_size, extract_conn(fetch_db_conn(&db_pool)?).deref_mut()),
None => CoursePackage::find_all_active_with_page(&keyword, page, page_size, extract_conn(fetch_db_conn(&db_pool)?).deref_mut()),
Some(org_id) => CoursePackage::find_all_published_by_org_with_page(org_id, &keyword, page, page_size, extract_conn(fetch_db_conn(&db_pool)?).deref_mut()),
None => CoursePackage::find_all_published_with_page(&keyword, page, page_size, extract_conn(fetch_db_conn(&db_pool)?).deref_mut()),
}
})();
match result {