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

Treemap and all elections totals table: Discuss new endpoints for /by_state and /by_state/by_district #5026

Closed
2 tasks
JonellaCulmer opened this issue Jan 19, 2022 · 2 comments · Fixed by #5090

Comments

@JonellaCulmer
Copy link
Contributor

JonellaCulmer commented Jan 19, 2022

What we're after:
We need to create new endpoints to support the work for the House and Senate treemap and all elections totals tables (see screenshots below). To do this, we will riff off the /totals/by_office/by_state endpoint. We would want to be able to grab all the states for senate elections, and use by_state/by_district to get states for House elections.

Proposed endpoints will be:

  • /candidates/totals/by_office/by_state
  • /candidates/totals/by_office/by_state/by_district

Action items:

  • Pass the two-year period as a filter grouped by state and district
  • We have total receipts, total disbursements.
  • Add cash on hand and debts to this endpoint
  • Should be no database work, fewer moving parts
  • Needs to be sortable

Completion criteria:

  • Have a meeting to discuss best way to create endpoint.
  • Create a ticket to implement new endpoints

Related tickets
#5027

This is the "treemap: feature mockup:
fecgov/fec-epics#213
Screen Shot 2022-03-10 at 7 40 35 PM


This is the All elections totals table mockup:
fecgov/fec-epics#216
Screen Shot 2022-03-10 at 7 46 52 PM

@JonellaCulmer JonellaCulmer transferred this issue from fecgov/fec-cms Jan 19, 2022
@johnnyporkchops johnnyporkchops changed the title Treemap and all elections totals table: Create new endpoints for /by_state and /by_state/by_district Treemap and all elections totals table: Discuss new endpoints for /by_state and /by_state/by_district Mar 10, 2022
@fec-jli
Copy link
Contributor

fec-jli commented Mar 11, 2022

Option one
The new endpoint: /candidates/totals/aggregate/
Parameter: aggregate_by (dropdown choice: office; state; district; party)
1)if aggregate_by = null (default) aggregate_by==> office
endpoint call url = /candidates/totals/aggregate/?aggregate_by=office
endpoint query logic: (group_by: election_year, office)
endpoint return
2002, S, $100
2002, S, $200
2002, H, $300
2002, H, $400
.......

2)if aggregate_by = states
endpoint call url = /candidates/totals/aggregate?aggregate_by=state
endpoint query logic: (group_by: election_year, office, state)
endpoint return (without district)
2002, S, CA, $100
2002, S, VA, $200
.......
2002, H, CA, $300
2002, H, VA, $400
....

3)if aggregate_by = districts
endpoint call url = /candidates/totals/aggregate/?aggregate_by=district
(only check for office = H)
endpoint query logic: (group_by: election_year, office, state, district)
Return result:
2000, H, CA, 01,$100
2000, H, CA, 02,$200
.....
2000, H, VA, 01,$300
2000, H, VA, 02,$400
.....

4)if aggregate_by = parties
endpoint call url = /candidates/totals/aggregate?aggregate_by=party
endpoint query logic: (group_by: election_year, office, party)
endpoint return
2002, S, DEM, $100
2002, S, REP, $200
2002, S, OTH, $300
.......
2002, H, DEM, $400
2002, H, REP, $500
2002, H, OTH, $600
....

Filters:
Parameters: office, state , election_year

@fec-jli
Copy link
Contributor

fec-jli commented Mar 13, 2022

Option two
The new endpoint: /candidates/totals/by_office/{aggregate_by}
1)if aggregate_by = by_state
endpoint url = /candidates/totals/by_office/by_state
endpoint logic: (group_by: election_year, office, state)
endpoint return (without district)
2002, S, CA, $100
2002, S, VA, $200
.......
2002, H, CA, $300
2002, H, VA, $400
....

2)if aggregate_by = by_district
endpoint url = /candidates/totals/by_office/by_district
(only for office = H)
endpoint logic: (group_by: election_year, office, state, district)
Return result:
2000, H, CA, 01,$100
2000, H, CA, 02,$200
2000, H, VA, 01,$300
2000, H, VA, 02,$400
.....

  1. keep the two current existing endpoints
    /candidates/totals/by_office/
    /candidates/totals/by_office/by_party

Filters:
Parameters: office, state , election_year

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants