Fix private message sort order. #4581 (#4587)

This commit is contained in:
Dessalines 2024-04-02 13:25:28 -04:00 committed by GitHub
parent ae9f82b452
commit 4d9c16a336
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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::<PrivateMessageReportView>(&mut conn)