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

Update WCCF PR H elections to four years #3329

Merged
merged 3 commits into from
Nov 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions fec/fec/static/js/widgets/contributions-by-state-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ function formatAsCurrency(passedValue, roundToWhole = true) {
* @param {String} stateID Optional. A null value will not filter for any state but show entries for the entire country
* @returns {String} URL or empty string depending on
*/
function buildIndividualContributionsUrl(cycle, office, committeeIDs, stateID) {
function buildIndividualContributionsUrl(
cycle,
office,
committeeIDs,
stateID,
candidateState
) {
// If we're missing required params, just return '' and be done
if (!cycle || !office || !committeeIDs) return '';

Expand All @@ -64,10 +70,13 @@ function buildIndividualContributionsUrl(cycle, office, committeeIDs, stateID) {

// The API currently wants a two_year_transaction_period value for each set of two years
// so we'll add the previous two-year period for presidential races
if (office == 'P')
//
// Also, Puerto Rico's House elections are for four years so we'll need to
// add the previous two-year period to the query string for House candidates from Puerto Rico
if (office == 'P' || (office == 'H' && candidateState == 'PR')) {
transactionPeriodsString += '&two_year_transaction_period=' + (cycle - 2);
patphongs marked this conversation as resolved.
Show resolved Hide resolved
// and the two earlier two-year periods for Senate races
else if (office == 'S') {
// and the two earlier two-year periods for Senate races
} else if (office == 'S') {
transactionPeriodsString += '&two_year_transaction_period=' + (cycle - 2);
transactionPeriodsString += '&two_year_transaction_period=' + (cycle - 4);
}
Expand Down Expand Up @@ -696,7 +705,8 @@ ContributionsByState.prototype.displayUpdatedData_states = function() {
this.baseStatesQuery.cycle,
this.baseStatesQuery.office,
theCommitteeIDs,
theResults[i].state
theResults[i].state,
this.candidateDetails.state
);

// Number cell
Expand Down