Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EREGCSC-2687 Fix for items with identical ranks being sorted in an undefined way #1528

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

cgodwin1
Copy link
Contributor

Resolves #2687

Description-

A while back we noticed an issue where differing page sizes would be sorted differently. Today a bug popped up where two nearly identical searches are being sorted differently. The only difference was that show_internal and show_regulations were both changed from true to false, as public items were always first in this particular search.

Noticed that the items in question had identical ranks (0.9999997) and realized that we are only sorting by rank and not specifying a secondary sort parameter for items with identical rank.

This PR fixes this (for now) by changing order_by("-rank") to order_by("-rank", "-id"). In theory this is a good approximation of sort by date as larger IDs should represent newer documents. In the future, we need to find a way to represent a date field in the Content Index model so we can do a proper sort by date for all Resource subtypes, but not Reg Text.

This pull request changes...

  • Added -id to the search result order_by, after -rank.

Steps to manually verify this change...

  1. Go to the experimental deploy.
  2. Log in to the admin panel, then navigate to the search page.
  3. Search for managed care SNP, and take note of the first few items which are all "public" resources.
  4. Click the "Public Resources" checkbox and wait for the page to reload.
  5. Ensure that the first few "public" resources are the same as before.

Copy link

✨ See the Django Site in action

Copy link

✨ See the Django Site in action

@cgodwin1 cgodwin1 marked this pull request as ready for review January 24, 2025 20:17
@cgodwin1 cgodwin1 requested a review from PhilR8 as a code owner January 24, 2025 20:17
@cgodwin1 cgodwin1 added the Needs Review This PR needs a code review label Jan 24, 2025
Copy link
Contributor

@PhilR8 PhilR8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@PhilR8 PhilR8 added Approved and removed Needs Review This PR needs a code review labels Jan 24, 2025
@cgodwin1 cgodwin1 merged commit 6da9e0c into main Jan 24, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants