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

Add endpoint /candidates/totals/aggregates/ #5090

Merged
merged 1 commit into from
Apr 4, 2022

Conversation

fec-jli
Copy link
Contributor

@fec-jli fec-jli commented Mar 26, 2022

Summary (required)

This new endpoint /candidates/totals/aggregates/ will consolidate other /candidates/totals/by_xxxx endpoints.
With passing parameters:

"aggregate_by": 
  [
  	  ""
	  "office", 
	  "office-state", 
	  "office-state-district", 
	  "office-party"
  ]

Page One (three endpoint call)
P1_HS_overview_page_org
1)aggregate_by=office; office=H; election_year=2022
sample endpoint url:
/candidates/totals/aggregates/?aggregate_by=office&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

local url:
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?aggregate_by=office&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

2)aggregate_by=office-party; office=H; election_year=2022
sample endpoint url:
/candidates/totals/aggregates/?aggregate_by=office-party&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

local url:
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?aggregate_by=office-party&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

3)aggregate_by=office; office=H; min_election_cycle; max_election_cycle
sample endpoint url:
/candidates/totals/aggregates/?aggregate_by=office&min_election_cycle=2018&max_election_cycle=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

local url
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?aggregate_by=office&min_election_cycle=2018&max_election_cycle=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

Page Two (two endpoint call)
P2_tree_map

1)aggregate_by=office-state; office=H; election_year=2022
sample endpoint url:
/candidates/totals/aggregates/?aggregate_by=office-state&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

local url:
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?aggregate_by=office-state&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

2)aggregate_by=office-state-district; office=H; election_year=2022; state=CA
sample endpoint url:
/candidates/totals/aggregates/?aggregate_by=office-state-district&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H&state=CA

local url:
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?aggregate_by=office-state-district&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H&state=CA

Page Three (one endpoint call)
P3_state_district_table

1)aggregate_by=office-state-district; election_year=2022; office=H
sample endpoint url:
/candidates/totals/aggregates/?aggregate_by=office-state-district&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

local url
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?aggregate_by=office-state-district&election_year=2022&election_full=true&is_active_candidate=true&per_page=100&office=H

Required reviewers

1-2 devs

Impacted areas of the application

/candidate/total/by_office/
/candidate/total/by_office/by_party/

How to test

(2)aggregate_by=office
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?election_year=2022&election_full=true&per_page=100&aggregate_by=office

(3)aggregate_by=office-state
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?election_year=2022&election_full=true&per_page=100&aggregate_by=office-state&state=CA

(4)aggregate_by=office-office-state-district
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?election_year=2022&election_full=true&per_page=100&aggregate_by=office-state-district

http://127.0.0.1:5000/v1/candidates/totals/aggregates/?page=1&aggregate_by=office-state-district&election_year=2022&election_full=true&sort_null_only=false&sort_nulls_last=false&sort_hide_null=false&per_page=100&state=CA

(5)aggregate_by=office-party
http://127.0.0.1:5000/v1/candidates/totals/aggregates/?election_year=2022&election_full=true&per_page=100&aggregate_by=office-party

@fec-jli fec-jli force-pushed the feature/create_candidate_total_offices_endpoint branch from 5daa885 to 1250e86 Compare March 28, 2022 17:28
@fec-jli fec-jli changed the title [WIP]Add endpoint /candidates/totals/aggregate/ Add endpoint /candidates/totals/aggregate/ Mar 28, 2022
Copy link
Contributor

@hcaofec hcaofec left a comment

Choose a reason for hiding this comment

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

Great work of creating this flexible endpoint!

@hcaofec hcaofec merged commit 75007c6 into develop Apr 4, 2022
@fec-jli fec-jli changed the title Add endpoint /candidates/totals/aggregate/ Add endpoint /candidates/totals/aggregates/ Apr 7, 2022
@fec-jli fec-jli deleted the feature/create_candidate_total_offices_endpoint branch February 13, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Treemap and all elections totals table: Discuss new endpoints for /by_state and /by_state/by_district
2 participants