Registrations and Reports should sort by New when viewing unresolved / unread. (#4207)

- Fixes #4206
This commit is contained in:
Dessalines 2023-11-29 05:08:23 -05:00 committed by GitHub
parent 23b266ec12
commit 86990d5138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 19 deletions

View File

@ -105,16 +105,18 @@ fn queries<'a>() -> Queries<
query = query.filter(post::community_id.eq(community_id));
}
// If viewing all reports, order by newest, but if viewing unresolved only, show the oldest first (FIFO)
if options.unresolved_only {
query = query.filter(comment_report::resolved.eq(false));
query = query
.filter(comment_report::resolved.eq(false))
.order_by(comment_report::published.asc());
} else {
query = query.order_by(comment_report::published.desc());
}
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
query = query
.order_by(comment_report::published.asc())
.limit(limit)
.offset(offset);
query = query.limit(limit).offset(offset);
// If its not an admin, get only the ones you mod
if !user.local_user.admin {
@ -475,8 +477,8 @@ mod tests {
assert_eq!(
reports,
[
expected_sara_report_view.clone(),
expected_jessica_report_view.clone(),
expected_sara_report_view.clone(),
]
);

View File

@ -83,16 +83,18 @@ fn queries<'a>() -> Queries<
query = query.filter(post::community_id.eq(community_id));
}
// If viewing all reports, order by newest, but if viewing unresolved only, show the oldest first (FIFO)
if options.unresolved_only {
query = query.filter(post_report::resolved.eq(false));
query = query
.filter(post_report::resolved.eq(false))
.order_by(post_report::published.asc());
} else {
query = query.order_by(post_report::published.desc());
}
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
query = query
.order_by(post_report::published.asc())
.limit(limit)
.offset(offset);
query = query.limit(limit).offset(offset);
// If its not an admin, get only the ones you mod
if !user.local_user.admin {
@ -337,8 +339,8 @@ mod tests {
.await
.unwrap();
assert_eq!(reports[0].creator.id, inserted_sara.id);
assert_eq!(reports[1].creator.id, inserted_jessica.id);
assert_eq!(reports[1].creator.id, inserted_sara.id);
assert_eq!(reports[0].creator.id, inserted_jessica.id);
// Make sure the counts are correct
let report_count = PostReportView::get_report_count(pool, inserted_timmy.id, false, None)

View File

@ -49,8 +49,13 @@ fn queries<'a>() -> Queries<
let list = move |mut conn: DbConn<'a>, options: RegistrationApplicationQuery| async move {
let mut query = all_joins(registration_application::table.into_boxed());
// If viewing all applications, order by newest, but if viewing unresolved only, show the oldest first (FIFO)
if options.unread_only {
query = query.filter(registration_application::admin_id.is_null())
query = query
.filter(registration_application::admin_id.is_null())
.order_by(registration_application::published.asc());
} else {
query = query.order_by(registration_application::published.desc());
}
if options.verified_email_only {
@ -59,10 +64,7 @@ fn queries<'a>() -> Queries<
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
query = query
.limit(limit)
.offset(offset)
.order_by(registration_application::published.asc());
query = query.limit(limit).offset(offset);
query.load::<RegistrationApplicationView>(&mut conn).await
};

View File

@ -55,7 +55,7 @@ services:
lemmy-ui:
# use "image" to pull down an already compiled lemmy-ui. make sure to comment out "build".
image: dessalines/lemmy-ui:0.19.0-rc.3
image: dessalines/lemmy-ui:0.19.0-rc.8
# platform: linux/x86_64 # no arm64 support. uncomment platform if using m1.
# use "build" to build your local lemmy ui image for development. make sure to comment out "image".
# run: docker compose up --build