-
Notifications
You must be signed in to change notification settings - Fork 106
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 optional parameter to sort nulls last #3474
Conversation
a9772fe
to
7342696
Compare
Codecov Report
@@ Coverage Diff @@
## develop #3474 +/- ##
===========================================
+ Coverage 88.67% 88.67% +<.01%
===========================================
Files 76 76
Lines 6323 6325 +2
===========================================
+ Hits 5607 5609 +2
Misses 716 716
Continue to review full report at Codecov.
|
It works great. |
Thanks for taking a look @fec-jli! While that’s my preference, I didn’t want to change the default behavior of the API - it’s arguably a breaking change to do so. |
This CMS PR will default the front-end data tables to always sort nulls last: |
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.
It works great. Thanks
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.
tests look good.
I am a little confused on those 2 arguments:
'default_sort_nulls_last=False, sort_nulls_last=False'- it seems like 'sort_nulls_last' is not used in the function.
It's good to add some doc string to the function we modified.
@qqss88 that's a good catch, thanks! They were unused so I removed them with my latest commit. I should have time to add docstrings, but I want to make sure I get my other issue for this sprint addressed first. |
Summary (required)
sa.nullslast
) sortCurrently, nulls will sort last by default when sorting ascending - this feature adds an optional
sort_nulls_last
parameter which forces nulls to the bottom for descending sort. The default behavior of the API is unchanged. This is needed for proper display of front-end data tables.How to test the changes locally
sort_nulls_last=true
parameter and nulls should appear on the last page instead of the first page: http://127.0.0.1:5000/v1/candidates/?api_key=DEMO_KEY&sort_hide_null=false&has_raised_funds=true&sort=-first_file_date&per_page=30&page=1&sort_nulls_last=trueImpacted areas of the application
List general components of the application that this PR will affect:
Related PRs
fecgov/fec-cms#2488
fecgov/fec-cms#2491