-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
declare namespace ElectionDataSource { | ||
/** ISO-formatted date, e.g. 2019-03-18T17:00:00.000Z */ | ||
type DateString = string | ||
|
||
/** | ||
* The summary file which contains all necessary data to render these sections. | ||
* | ||
* - Nationwide summary | ||
* - Filtered summary | ||
* - Election map | ||
*/ | ||
interface SummaryJSON { | ||
updatedAt: DateString | ||
zoneWinnerMap: ZoneWinnerMap | ||
zoneStatsMap: ZoneStatsMap | ||
partyScoreMap: PartyScoreMap | ||
} | ||
|
||
/** | ||
* Information representing the highest-voted candidate for each district. | ||
*/ | ||
interface ZoneWinnerMap { | ||
[provinceId: string]: { | ||
[zoneNo: string]: { | ||
/** Candidate number */ | ||
no: number | ||
/** Score (number of votes) */ | ||
score: number | ||
/** Party ID */ | ||
partyId: number | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Information representing the number of people who voted in each zone. | ||
* | ||
* This is required for calculating: | ||
* - how many people voted (in total, as well as in filtered views) | ||
* - stats for overview page | ||
*/ | ||
interface ZoneStatsMap { | ||
[provinceId: string]: { | ||
[zoneId: string]: { | ||
/** Number of election units */ | ||
units: number | ||
/** Number of eligible voters */ | ||
eligible: number | ||
/** Number of voters who voted = (goodVotes + badVotes) = (votesM + votesF) */ | ||
votesTotal: number | ||
/** Number of men who voted */ | ||
votesM: number | ||
/** Number of women who voted */ | ||
votesF: number | ||
/** Number of votes that are valid */ | ||
goodVotes: number | ||
/** Number of votes that are invalid */ | ||
badVotes: number | ||
/** Number of "no" votes (also counted as a good vote) */ | ||
noVotes: number | ||
|
||
// @todo #1 How do we determine when vote counting for a certain zone is finished? | ||
// The problem is, we don’t know beforehand how many ballots we received. | ||
// And it also seems like the official API doesn’t provide the information | ||
// on progress of each zone, or whether the counting has finished. | ||
// Need to check with the committee to see if the data will be available, | ||
// and if not, decide the appropriate adjustments to the app. | ||
// | ||
/** Vote counting progress, between 0-1 */ | ||
progress: number | ||
/** True if counting finished */ | ||
finished: boolean | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* The total score each party received, aggregated nationwide. | ||
* | ||
* This is required for calculating: | ||
* - Party list member count for each party. | ||
*/ | ||
interface PartyScoreMap { | ||
[partyNo: string]: { | ||
score: number | ||
} | ||
} | ||
|
||
// @todo #1 Define JSON data format for each province. | ||
// This data should contain necessary information to display | ||
// - Per-zone summary | ||
} |
8d6a1a2
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.
Puzzle
1-2a60074f
discovered insrc/models/datasource.d.ts
and submitted as #23. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.8d6a1a2
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.
Puzzle
1-72b33c4d
discovered insrc/models/datasource.d.ts
and submitted as #24. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.