alex / nyt-2020-election-scraper

Home Page:https://alex.github.io/nyt-2020-election-scraper/battleground-state-changes.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use state abbreviations in notifications

berkowitze opened this issue · comments

Is your feature request related to any of these? We are not pursuing these at the moment.
No it is not :)

  • graphs and data visualizations
  • projections and regression models
  • additional data added to the top of the page
  • changes to the hurdle rate. please see #194; the hurdle rate is not incorrect.

This isn't really a big deal, but currently if enough states add votes you can't necessarily see all of them in the notification:
image

Proposal: Add a stateToAbbreviation object that translates state name to state abbreviation (i.e. "Pennsylvania" -> "PA"), and in the new Notification call map over latestMetadata.states_updated using that object. The result would be a notification with text "New ballots counted in: PA, GA, AZ".

Happy to open a PR to do this (already have the code though don't know how to compile the template files to test it).

Sure! We'd absolutely accept a PR to implement this. You can test by doing the following:

  1. pip install -r requirements.txt (you may want to set up a virtualenv)
  2. ./print-battleground-state-changes (this generates the HTML files)
  3. Start a HTTP server with python -m http.server and open the HTML file in your browser from the server.
  4. Edit the generated HTML file: change the results_hash and add one or more states to the states_updated array in the page-metadata JSON and save the file.
  5. The loaded HTML will be auto-refreshing and should pick up the changes and fire the notification.

Let me know if you have any questions or trouble with that!

Awesome!

PR: #379