Skip to content

Implementation

Roderick Monje edited this page Nov 29, 2021 · 7 revisions

@vaccinesignup is a Twitter bot that notifies users who DM their zip codes about available vaccine-appointment Locations in their area.

This file provides information on how it's implemented, in the hopes that it will help people make improvements. Many of these sections are notes on how to repeat some task in the future, or notes that may help future changes. This document is named "implementation", but it also covers verification issues including testing.

See CONTRIBUTING.md for information on how to contribute to this project, and the developers section of the README for information on both how to install this software and a quick-start guide.

If you have the privilege to access the production database directly, or any copy of it, be especially careful about protecting it. We want to ensure we comply with various laws about user privacy, including the EU General Data Protection Regulation (GDPR).

In this document we'll use the term "open source software" (OSS), and treat Free/Libre and Open Source Software (FLOSS) as a synonym.

Running locally

  1. Configure environment variables

    a. The six environment variables, used to configure the Postgres and Twitter clients, are summarized in the README.

    b. On Heroku, using config:set to set a value will automatically restart the application, causing it to take effect.

    The TZ (timezone) environment variable is set to ":/usr/share/zoneinfo/UTC" on all tiers. We want all logging to be done in UTC (because then moving the servers has no affect on logs). Using leading-colon helps performance on many systems, especially many Rails systems (because it skips many system calls), and it's easy enough to do. More information is at How setting the TZ environment variable avoids thousands of system calls. This was implemented with:

    heroku config:set --app vaccinesignup TZ=:/usr/share/zoneinfo/UTC
  2. Sync your local staging environment with production via:

    bundle ex rake vaccinesignup:reset_staging
  3. Run the two main tasks to read DMs and sync Locations, both of which send notifications regarding any changes:

    rake vaccinesignup:read_and_notify      # Read DMs and, if there are subscribed zip codes, notify users
    rake vaccinesignup:sync_and_notify      # Sync Locations and, if there are changes, notify users

    The README documents all available tasks.

Security

See the separate security document for more about security.

Cleaning up development environment storage space

If you develop for a period of time within an environment, you may start to run short of storage space. If so, here are some steps you can take:

Remove old logs

The file log/test.log, in particular, gets huge if you routinely run tests locally.

    rake log:clear

Remove Ruby packages for Ruby versions you don't use

    rbenv uninstall [version number]

Reduce git repo size

Running git's garbage collector manually may give you a few K, but is unlikely to help much, because git occasionally runs it automatically. That said, there's no harm in running it, here's how:

    git gc