Skip to content

Commit 2ec1e7c

Browse files
committed
project status filter
1 parent 518a5c2 commit 2ec1e7c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

apps/labrinth/.sqlx/query-011ada1d529754f2e6b8efd6588be6e5ac428593e82b544ec982f6fe9c18cc90.json renamed to apps/labrinth/.sqlx/query-b55d397b08c2aacd97f4d0dad4f716505dc7970832d244412756d97d2d86722a.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/src/routes/internal/moderation/tech_review.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ pub struct SearchProjectsFilter {
7373
pub project_type: Vec<ProjectTypeId>,
7474
#[serde(default)]
7575
pub replied_to: Option<RepliedTo>,
76+
#[serde(default)]
77+
pub project_status: Vec<ProjectStatus>,
7678
}
7779

7880
/// Filter by whether a moderator has replied to the last message in the
@@ -524,11 +526,13 @@ async fn search_projects(
524526
-- project type
525527
(cardinality($4::int[]) = 0 OR c.project_type = ANY($4::int[]))
526528
AND m.status NOT IN ('draft', 'rejected', 'withheld')
529+
-- project status
530+
AND (cardinality($6::text[]) = 0 OR m.status = ANY($6::text[]))
527531
-- replied/unreplied filter
528532
AND (
529533
$5::text IS NULL
530-
OR ($5::text = 'replied' AND (tm_last.id IS NULL OR u_last.role IS NULL OR u_last.role NOT IN ('moderator', 'admin')))
531-
OR ($5::text = 'unreplied' AND tm_last.id IS NOT NULL AND u_last.role IS NOT NULL AND u_last.role IN ('moderator', 'admin'))
534+
OR ($5::text = 'unreplied' AND (tm_last.id IS NULL OR u_last.role IS NULL OR u_last.role NOT IN ('moderator', 'admin')))
535+
OR ($5::text = 'replied' AND tm_last.id IS NOT NULL AND u_last.role IS NOT NULL AND u_last.role IN ('moderator', 'admin'))
532536
)
533537
534538
GROUP BY m.id, t.id
@@ -555,6 +559,12 @@ async fn search_projects(
555559
.map(|ty| ty.0)
556560
.collect::<Vec<_>>(),
557561
replied_to_filter.as_deref(),
562+
&search_req
563+
.filter
564+
.project_status
565+
.iter()
566+
.map(|status| status.to_string())
567+
.collect::<Vec<_>>()
558568
)
559569
.fetch(&**pool);
560570

0 commit comments

Comments
 (0)