From 4d9c16a336d40190bce51a67acd5ace3ae79cff1 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 2 Apr 2024 13:25:28 -0400 Subject: [PATCH] Fix private message sort order. #4581 (#4587) --- crates/db_views/src/private_message_report_view.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/db_views/src/private_message_report_view.rs b/crates/db_views/src/private_message_report_view.rs index 091071b16..dff9820d9 100644 --- a/crates/db_views/src/private_message_report_view.rs +++ b/crates/db_views/src/private_message_report_view.rs @@ -49,14 +49,18 @@ fn queries<'a>() -> Queries< let list = move |mut conn: DbConn<'a>, options: PrivateMessageReportQuery| async move { let mut query = all_joins(private_message_report::table.into_boxed()); + // If viewing all reports, order by newest, but if viewing unresolved only, show the oldest first (FIFO) if options.unresolved_only { - query = query.filter(private_message_report::resolved.eq(false)); + query = query + .filter(private_message_report::resolved.eq(false)) + .order_by(private_message_report::published.asc()); + } else { + query = query.order_by(private_message_report::published.desc()); } let (limit, offset) = limit_and_offset(options.page, options.limit)?; query - .order_by(private_message::published.asc()) .limit(limit) .offset(offset) .load::(&mut conn)