Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Copy link

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.

- To keep this very simple, the dataset is statically hosted in this github repo in `./data.db`
+ To simplify, the dataset is statically hosted in this github repo in `./data.db`
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
To keep this very simple, the dataset is statically hosted in this github repo in `./data.db`
To simplify, the dataset is statically hosted in this github repo in `./data.db`
Tools
LanguageTool

[style] ~24-~24: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase. (EN_WEAK_ADJECTIVE)
Context: ...ng results to the dataset To keep this very simple, the dataset is statically hosted in th...


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
Copy link

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Deployment
## Deployment
Tools
Markdownlint

30-30: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines

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
Copy link

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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.
Tools
LanguageTool

[uncategorized] ~31-~31: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...n github pages. Merge to main and it'll auto deploy. Site is hosted on github pages. Merge ...


[uncategorized] ~31-~31: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...s. Merge to main and it'll auto deploy. Site is hosted on github pages. Merge to mai...


Binary file modified data.db
Binary file not shown.
85 changes: 85 additions & 0 deletions load-report.js
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");
58 changes: 0 additions & 58 deletions load-reports.js

This file was deleted.

58 changes: 0 additions & 58 deletions load-reports.ts

This file was deleted.

Loading