Skip to content

Commit

Permalink
uses new columns of splits for getting election types and dates
Browse files Browse the repository at this point in the history
  • Loading branch information
ajrothwell committed Jul 25, 2024
1 parent 9a2ca97 commit 3661398
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev_push_to_s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: dev Push to S3
on:
push:
branches:
- feature/new-zoning-tiles
- election-dates

jobs:
build:
Expand Down
13 changes: 13 additions & 0 deletions src/data-sources/election-splits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
id: 'electionSplits',
type: 'http-get',
url: 'https://phl.carto.com/api/v2/sql',
options: {
params: {
q: function(feature){
// console.log(feature.properties.election_precinct);
return "SELECT * FROM splits WHERE precinct = '" + feature.properties.election_precinct + "'";
},
},
},
};
3 changes: 3 additions & 0 deletions src/i18n/en-us.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export default {
"p5": "If you are planning on voting in person, please confirm your polling place and make voting arrangements prior to the election.",
},
"badge1": {
"specialElection": "Next Eligible Election: Special Election",
"primaryElection": "Next Eligible Election: Primary Election",
"generalElection": "Next Eligible Election: General Election",
"header": "Next Eligible Election Is",
"content": "November 3, 2020",
},
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export default {
"p5": "Si planea ir a votar en persona, confirme su lugar de votación y haga los arreglos necesarios para la votación antes de la elección.",
},
"badge1": {
"specialElection": "Próxima Elección Elegible: Elección Especial",
"primaryElection": "Próxima Elección Elegible: Elección Primaria",
"generalElection": "Próxima Elección Elegible: Elección General",
"header": "La próxima elección es el",
"content": "3 de noviembre de 2020",
},
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import divisions from './data-sources/divisions';
import dorCondoList from './data-sources/dor-condo-list';
import dorDocuments from './data-sources/dor-documents';
import electedOfficials from './data-sources/elected-officials';
import electionSplits from './data-sources/election-splits';
// import electedOfficialsFuture from './data-sources/elected-officials-future';
import liBusinessLicenses from './data-sources/li-business-licenses';
import liBuildingCertSummary from './data-sources/li-building-cert-summary';
Expand Down Expand Up @@ -219,6 +220,7 @@ mapboard({
dorCondoList,
dorDocuments,
electedOfficials,
electionSplits,
// electedOfficialsFuture,
liBusinessLicenses,
liBuildingCertSummary,
Expand Down
20 changes: 17 additions & 3 deletions src/topics/voting.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
key: 'voting',
icon: 'gavel',
label: 'Voting',
dataSources: [ 'divisions', 'pollingPlaces', 'electedOfficials', 'nextElectionAPI' ],
dataSources: [ 'divisions', 'pollingPlaces', 'electedOfficials', 'nextElectionAPI', 'electionSplits' ],
errorMessage: function() {
return 'No voting assignment found for this address.';
},
Expand Down Expand Up @@ -40,11 +40,25 @@ export default {
},
},
slots: {
title: 'voting.topic.badge1.header',
title: function(state) {
let value;
if (state.sources.electionSplits.data.rows[0].election_type == 0) {
value = 'voting.topic.badge1.specialElection';
} else if (state.sources.electionSplits.data.rows[0].election_type == 1) {
value = 'voting.topic.badge1.primaryElection';
} else if (state.sources.electionSplits.data.rows[0].election_type == 2) {
value = 'voting.topic.badge1.generalElection';
} else {
value = 'voting.topic.badge1.header';
}
return value;
},
titleBackground: '#2176d2',
value: function(state) {
// return 'voting.topic.badge1.content';
return format(parseISO(state.sources.nextElectionAPI.data.election_count_down_settings.election_day), 'MMMM d, yyyy');
// let value;
// if (state.sources.electionSplits.data) {
return format(parseISO(state.sources.electionSplits.data.rows[0].election_date), 'MMMM d, yyyy');
},
}, // end slots
}, // end of badge
Expand Down

0 comments on commit 3661398

Please sign in to comment.