-
Notifications
You must be signed in to change notification settings - Fork 105
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
Counts for all endpoints are incorrect when 'sort_hide_null=True' #4626
Comments
sort_hide_null = True: SELECT count(*) FROM ofec_candidate_detail_mv
LEFT OUTER JOIN ofec_candidate_flag_mv
AS ofec_candidate_flag_mv_1
ON ofec_candidate_flag_mv_1.candidate_id = ofec_candidate_detail_mv.candidate_id
WHERE ofec_candidate_detail_mv.candidate_inactive = false
AND ofec_candidate_detail_mv.first_file_date is not NULL;
=> 33048 sort_hide_null = False: SELECT count(*) FROM ofec_candidate_detail_mv
LEFT OUTER JOIN ofec_candidate_flag_mv
AS ofec_candidate_flag_mv_1
ON ofec_candidate_flag_mv_1.candidate_id = ofec_candidate_detail_mv.candidate_id
WHERE ofec_candidate_detail_mv.candidate_inactive = false ;
=> 42857 |
A tracing of the logic for https://api.open.fec.gov/v1/candidates/?api_key=DEMO_KEY&sort_hide_null=true&sort_nulls_last=true&is_active_candidate=true&sort=-first_file_date:
Passing |
User story
As a user, I want the endpoints to return correct counts when I use
sort_hide_null=True
because I want accurate results.Expected behavior
When we use
sort_hide_null=True
, it's supposed to hide rows that have null values for whatever we are sorting on (e.g.,first_file_date
(We want count to reflect the number of rows that are shown)
Actual behavior
Examples of incorrect behavior:
https://api.open.fec.gov/v1/candidates/?api_key=DEMO_KEY&sort_hide_null=true&sort_nulls_last=true&is_active_candidate=true&sort=-first_file_date
is the same count as
https://api.open.fec.gov/v1/candidates/?api_key=DEMO_KEY&sort_hide_null=false&sort_nulls_last=true&is_active_candidate=true&sort=-first_file_date&per_page=100 ➡️ when I confirmed there are records with null
first_file_date
values.https://api.open.fec.gov/v1/schedules/schedule_a/?api_key=DEMO_KEY&sort_hide_null=true&sort_nulls_last=false&data_type=processed&committee_id=C00671339&line_number=F3-11AI&sort=-contribution_receipt_date&per_page=100&two_year_transaction_period=2020
➡️ shows count of 3 and no results
This applies to ItemizedResource and ApiResource endpoints. This means the counts are wrong, and makes pagination really tough because it looks like there are more records than there are. I'm not sure this impacts front-end users.
I put some tests in the
4626-tests
branch: ff8ab0aCompletion criteria
sort_hide_null=True
sort_nulls_only=True
Helpful additions:
This is an example of an API resource being ok (updating counts correctly):
https://api.open.fec.gov/v1/candidates/?api_key=DEMO_KEY&sort_nulls_only=true&sort_nulls_last=true&is_active_candidate=true&sort=-first_file_date&per_page=100
The text was updated successfully, but these errors were encountered: