Skip to content

Prototype of email alerts whenever campaign finance disclosures come in

Notifications You must be signed in to change notification settings

openoakland/disclosure-alert

Repository files navigation

local setup:

# install and start PostgreSQL:
brew install postgresql
brew services start postgresql

# create the postgresql database:
createdb disclosure-alert
createdb disclosure-alert_test

# install ruby
# We recommend doing it with rbenv, there are instructions here:
# https://github.com/rbenv/rbenv#homebrew-on-macos
# After installing rbenv:
rbenv install         # <- this installs ruby

# install ruby dependencies:
gem install bundler
bundle install

# initialize the database
bin/rails db:schema:load

# run the server!!
bin/rails server      # <- check it out at http://localhost:3000

# view the email rendering in-browser:
bin/rails disclosure_alert:download      # <- download the filings
# then: go to this URL:
open http://localhost:3000/rails/mailers/alert_mailer/daily_alert


# if you subscribe using the web interface, you can generate an email to
# yourself. First, you will need to configure Mailgun. Get the value from Tom or
# set up your own mailgun account. Then:
cp .env.development .env.local
# edit .env.local and put the API key value in there
bin/rails disclosure_alert:download_and_email_daily

deploying to Heroku:

heroku create disclosure-alert
heroku git:remote --app disclosure-alert
heroku addons:create heroku-postgresql:hobby-dev
heroku addons:create scheduler:standard
heroku config:set MAILGUN_API_KEY=key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
heroku config:set APP_HOST=your-app-name.herokuapp.com
heroku addons:open scheduler
# create a scheduled task for:
bin/rails disclosure_alert:download_and_email_daily
# that runs daily at 11:00UTC (4am PDT)

deploying:

git push heroku master
heroku run bin/rails db:migrate

running:

heroku run bin/rails disclosure_alert:add_daily_subscriber
heroku run bin/rails disclosure_alert:download_and_email_daily

getting production data onto your local machine:

dropdb disclosure-alert && heroku pg:pull DATABASE_URL $DATABASE_URL
echo "update alert_subscribers set email = concat('tomdooner+', id, '@gmail.com')" | psql disclosure-alert
echo "update ahoy_messages set \"to\" = concat('tomdooner+', user_id, '@gmail.com')" | psql disclosure-alert

About

Prototype of email alerts whenever campaign finance disclosures come in

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •