Skip to content

Commit

Permalink
added last updated date for dc election results
Browse files Browse the repository at this point in the history
  • Loading branch information
tonmcg committed Dec 3, 2024
1 parent 549e78b commit eb3912a
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,31 @@
<v-row class="align-center">
<v-col>
<span>
Source:
Sources:
<a href="https://www.foxnews.com/elections/2024/general-results"
target="_blank"><em>Fox News</em></a>, the
target="_blank"><em>Fox News</em></a>,
<a href="https://electionresults.dcboe.org/election_results/2024-General-Election"
target="_blank"><em>District of Columbia Board of Elections</em></a>, and
the
<a href="https://www.elections.alaska.gov/enr/" target="_blank"><em>Alaska
Division of Elections</em></a>. Data compiled by:
Division of Elections</em></a>.
<br />Data compiled by:
<a href="https://github.com/tonmcg/US_County_Level_Election_Results_08-24/blob/master/2024_US_County_Level_Presidential_Results.csv"
target="_blank">Tony McGovern</a>. Alaska data last updated: {{
alaska.lastupdated
}}. Continental U.S. data last updated: {{ continental.lastupdated }}.
target="_blank">Tony McGovern</a>.
</span>
</v-col>
<v-col class="d-flex justify-end" cols="auto">
<span>
Alaska data last updated: {{ alaska.lastupdated }}.
<br />Washington D.C. data last updated: {{ dc.lastupdated }}.
<br />Continental U.S. data last updated: {{ continental.lastupdated }}.

</span>
<br />
<span>Hover over and click on the map to explore</span>
</v-col>
</v-row>
<v-row>
<v-col>
<br /><span>Hover over and click on the map to explore</span>
</v-col>
<v-col class="d-flex justify-end" cols="auto">
<v-radio-group v-model="selectedMap" row @change="renderMap">
<template v-slot:label>
Expand Down Expand Up @@ -338,6 +345,9 @@
alaska: {
lastupdated: ""
},
dc: {
lastupdated: ""
},
continental: {
lastupdated: new Date().toLocaleString(),
},
Expand Down Expand Up @@ -381,6 +391,7 @@
);
const dcGeographies = await this.getDCGeographies();
await this.fetchDCResults(dcGeographies);
await this.fetchDCUpdatedDate();
const akGeographies = await this.getAlaskaGeographies();
await this.fetchAlaskaResults(akGeographies);
await this.fetchElectionResults(censusStates, censusGeographies);
Expand Down Expand Up @@ -975,6 +986,14 @@
);
this.districtObj = { ...this.districtObj, ...countyResults };
},
async fetchDCUpdatedDate() {
// Fetch the JSON data from the API
const url = `https://us-election-server-2ae36243a2a4.herokuapp.com/dc/results/lastUpdated`;
const response = await fetch(url);
const data = await response.json();

this.dc.lastupdated = new Date(data.LastUpdated).toLocaleString();
},
async fetchAlaskaResults(akGeographies) {
try {
// Fetch the JSON data
Expand Down

0 comments on commit eb3912a

Please sign in to comment.