Election scraping#2178
Open
delexagon wants to merge 4 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backend pipeline for #2130.
Known issues
I strongly recommend looking over the data definitions in
functions/src/legislators/electionTypes.ts.If there are more than 1200 elections in a search (in our case, more than 1200 general elections in a year), they will be clipped off at 1200. Currently, the scraper does not catch this case.
The id is a hash of the data. If we want to normalize the district data to a standard format, this would change all the ids.
We should probably consider how we are going to want to connect the candidate url used as a key here to the legislator elsewhere.
May want to discuss whether there are a possibility of additional 'types' of votes like no preference, which may be rare but existing.
Does not currently check if all the votes add up to the total, which might be desirable.
Steps to test/reproduce
curl 'http://localhost:5001/demo-dtp/us-central1/triggerPubsubFunction?scheduled=scrapeElections'. This should fetch all elections for this year (and last year if before July).yarn firebase-admin run-script backfillElections --env local --startYear 2024. This should fetch every general election from 2024.npx ts-node --compiler-options '{"module":"CommonJS"}' functions/src/legislators/scrapeElections.tswith