-
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
[WIP]refactor elections endpoint to enable candidate financial totals export #3253
Conversation
1)refactor ElectionView extand ApiResource. 2)add CandidateCommitteeLink.committee_designation.in_(['P', 'A']) to remove joint fundraisers committees inflated figures from total
Apropos of our conversation on a clean
Also, it would be easier for the reviewer if you rebased this on |
@vrajmohan since this is targeting the release branch, should @fec-jli rebase off the release branch? |
Right, good catch! |
@@ -280,6 +288,7 @@ def join_candidate_totals(query, kwargs, totals_model): | |||
sa.and_( | |||
CandidateHistory.candidate_id == CandidateCommitteeLink.candidate_id, | |||
CandidateHistory.two_year_period == CandidateCommitteeLink.fec_election_year, | |||
CandidateCommitteeLink.committee_designation.in_(['P', 'A']), |
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.
A comment on why this is needed may be useful. Also, should we create a test that would add other committee designations and assert that they are not picked up?
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.
Here is a comment on why this is needed:
Joint Fundraising Committees raise money for multiple candidate committees and transfer that money to those committees. By limiting the committee designations to A and P you eliminate J (joint) and thus do not inflate the candidate's money by including it twice and by including money that was raised and transferred to the other committees in the joint fundraiser.
@fec-jli I changed the target branch back to |
@fec-jli Closing this PR in favor of a more up-to-date PR. |
Summary (required)
in order to enable “candidate financial totals” data in election summery page, we need refactor election endpoint to extend ApiResource and overwrite 'build_query()'
Research to see if we can use candidate/totals endpoint instead of elections endpoint fec-cms#2010
enable the export link for “candidate financial totals” section in election summary page:
example link on prod which is disable now:
https://www.fec.gov/data/elections/senate/VA/2018/
openFEC Issue: Refactor elections (ElectionView) endpoint to extend ApiResource
#3254
How to test the changes locally
This PR involves changes on both fec-cms and openFEC side.
export FEC_WEB_API_KEY_PUBLIC=xxxxxxx
export FEC_WEB_API_KEY=xxxxxxx
export FEC_CMS_ENVIRONMENT=LOCAL
export FEC_API_URL=http://localhost:5000
export DATABASE_URL=postgresql://:@/cfdm_cms_test
2)check out openFEC feature branch: feature/fix_elections_download
setup openFEC local (env api variables)
export SQLA_CONN=xxxxxxx
export access_key_id=
export secret_access_key=
export bucket=
export region=
3)start redis-server
4)Setup Celery Worker and start
export SQLA_CONN=xxxxxxx
export access_key_id=
export secret_access_key=
export bucket=
export region=
5)example url: http://127.0.0.1:8000/data/elections/senate/VA/2018/
Click "Export" on Candidate financial totals section, download the file.