-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Adding Fargo 06/2024 election for City Commissioner #16
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -19,7 +19,15 @@ npm run build | |||||||
|
||||||||
You can preview the production build with `npm run preview`. | ||||||||
|
||||||||
## Deployment | ||||||||
## Adding results to the dataset | ||||||||
|
||||||||
To keep this very simple, the dataset is statically hosted in this github repo in `./data.db` | ||||||||
|
||||||||
To add to the report, edit `./load-report.js` with the data from the election. | ||||||||
|
||||||||
Site is hosted on github pages. Merge to main and it'll auto deploy. | ||||||||
Submit a pull request with the updated `data.db`. | ||||||||
|
||||||||
## Deployment | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure headings are surrounded by blank lines for proper markdown formatting. +
## Deployment Committable suggestion
Suggested change
ToolsMarkdownlint
|
||||||||
The site is hosted on github pages. Merge to main and it'll auto deploy. | ||||||||
Site is hosted on github pages. Merge to main and it'll auto-deploy. | ||||||||
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the repeated and inconsistent deployment instructions. - The site is hosted on github pages. Merge to main and it'll auto deploy.
- Site is hosted on github pages. Merge to main and it'll auto-deploy.
+ The site is hosted on GitHub pages. Merge to main and it will auto-deploy. Committable suggestion
Suggested change
ToolsLanguageTool
|
||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import Database from "better-sqlite3"; | ||
|
||
// Path to your SQLite database file | ||
const db = new Database("data.db"); | ||
|
||
const insertReport = db.prepare(` | ||
INSERT INTO reports (name, date, jurisdictionPath, electionPath, office, officeName, jurisdictionName, electionName, website, notes, ballotCount, path, hidden) | ||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) | ||
`); | ||
|
||
const insertCandidate = db.prepare(` | ||
INSERT INTO candidates (report_id, name, votes, winner) | ||
VALUES (?, ?, ?, ?) | ||
`); | ||
|
||
function addReportAndCandidates(report, candidates) { | ||
// Start a transaction | ||
const transaction = db.transaction(() => { | ||
// Insert the report | ||
const result = insertReport.run( | ||
report.name, | ||
report.date, | ||
report.jurisdictionPath, | ||
report.electionPath, | ||
report.office, | ||
report.officeName, | ||
report.jurisdictionName, | ||
report.electionName, | ||
report.website, | ||
report.notes, | ||
report.ballotCount, | ||
report.path, | ||
report.hidden | ||
); | ||
|
||
// Get the last inserted row ID | ||
const reportId = result.lastInsertRowid; | ||
|
||
// Insert candidates | ||
for (const candidate of candidates) { | ||
insertCandidate.run(reportId, candidate.name, candidate.votes, candidate.winner); | ||
} | ||
}); | ||
|
||
// Execute the transaction | ||
try { | ||
transaction(); | ||
console.log("Transaction successful."); | ||
} catch (error) { | ||
console.error("Failed to execute transaction:", error); | ||
} | ||
} | ||
|
||
// Example data to insert | ||
const report = { | ||
name: "June 11, 2024 Commissioner Fargo", | ||
date: "2024-06-11", | ||
jurisdictionPath: "us/nd/fargo", | ||
electionPath: "2024/06", | ||
office: "commissioner", | ||
officeName: "City Commissioner", | ||
jurisdictionName: "Fargo, ND", | ||
electionName: "Primary Election", | ||
website: "https://results.sos.nd.gov/resultsSW.aspx?text=All&type=CIALL&map=CTY&area=Fargo&name=Fargo", | ||
notes: "", | ||
ballotCount: 14781, | ||
path: "us/nd/fargo/2024/06", | ||
hidden: 0 | ||
}; | ||
|
||
const candidates = [ | ||
{ name: "Michelle Turnberg", votes: 6850, winner: 1 }, | ||
{ name: "John Strand", votes: 6579, winner: 1 }, | ||
{ name: "Al Carlson", votes: 5746, winner: 0 }, | ||
{ name: "Arlette Preston", votes: 5560, winner: 0 }, | ||
{ name: "Anna Johnson", votes: 3545, winner: 0 }, | ||
{ name: "Delson Saintal", votes: 2378, winner: 0 }, | ||
{ name: "Nathan Pullen", votes: 1879, winner: 0 }, | ||
{ name: "write-in", votes: 85, winner: 0 } | ||
]; | ||
|
||
// Add the report and candidates to the database | ||
addReportAndCandidates(report, candidates); | ||
|
||
console.log("Report and candidates added successfully"); |
This file was deleted.
This file was deleted.
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.
Consider replacing "very simple" with a more precise description.
Committable suggestion
Tools
LanguageTool