-
Notifications
You must be signed in to change notification settings - Fork 261
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
Add patient ordering by category #1235
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #1235 +/- ##
==========================================
- Coverage 56.22% 56.20% -0.02%
==========================================
Files 193 193
Lines 9491 9502 +11
Branches 1600 1604 +4
==========================================
+ Hits 5336 5341 +5
- Misses 4100 4106 +6
Partials 55 55
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a requirement then i would recommend creating a migration and moving the values into something that is queryable. Do create an issue for that and track separately.
default=(len(category_ordering) + 1), | ||
output_field=models.IntegerField(), | ||
) | ||
).order_by(ordering) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you be ordering based on the new annotated field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vigneshhari That is being already done, the annotated field is category_severity
and here (.order_by(ordering)
) ordering
can be either category_severity
or -category_severity
.
For the separate issue, you mean a migration to move the values to numeric? So that we can return the category sorted in any order without needing a custom |
Required for: coronasafe/care_fe#5197
This PR adds a new filter backend,
PatientCustomOrderingFilter
, to allow custom ordering of thePatient
queryset based on thecategory_severity
field. This field is annotated using aCase
statement that maps each category value to its corresponding severity order. The filter backend accepts a new query parameterordering
to specify the ordering direction, which can be either ascending or descending.This change also imports the
Case
andWhen
classes fromdjango.db.models
to be used in the PatientCustomOrderingFilter`implementation.
Overall, this PR enhances the functionality of the
PatientViewSet
by providing a new custom ordering option based on the severity of the patient's category.@coronasafe/code-reviewers