Skip to content

Commit

Permalink
Merge pull request #3329 from fecgov/feature/3290-wccf-puerto-rico-ho…
Browse files Browse the repository at this point in the history
…use-four-years

Update WCCF PR H elections to four years
  • Loading branch information
patphongs authored Nov 14, 2019
2 parents f4f8295 + fee22b9 commit 40336a7
Showing 1 changed file with 15 additions and 5 deletions.
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);
// 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

0 comments on commit 40336a7

Please sign in to comment.