web-monitoring-db
We're excited to work with you! We've moved our Sprint-specific intro material into a HackPad -- please check it out in its new location!
This repository is the database and API underlying the EDGI Web Monitoring Project.
It’s a Rails app that:
- Acts as a database of monitored pages and revisions that have been made to them
- Allows other services to add new tracked pages/versions (we are currently focused on Versionista, but this database will soon host data from other sources, such as the Internet Archive)
- Provides an API to get that version data and allow analysts or other automated tools to annotate those versions with metadata
Installation
-
Ensure you have Ruby 2.4.1+
-
Ensure you have PostgreSQL 9.5+
-
Ensure you have Redis
On OSX:
$ brew install redis
On Debian Linux:
$ apt-get install redis
-
Clone this repo
-
If you don’t have the
bundler
Ruby gem, install it:$ gem install bundler
-
Wherever you cloned the repo, go to that directory and install dependencies:
$ bundle install --without production
-
Set up your database. The simple way to do this is:
$ bundle exec rake db:setup
That will create a database, set up all the tables, create an admin user, and add some sample data. Make note of the admin user e-mail and password that are shown; you’ll need them to log in and create more users, import more data, or make annotations.
If you’d like to do the setup manually, see advanced setup below.
-
Start the server!
$ bundle exec rails server
You should now have a server running and can visit it at http://localhost:3000/. Open that up in a browser and go to town!
-
Bulk importing (and, in the future, potentially other features) make use of a Redis queue. If you plan to use any of these features, you must also start a Redis server and worker.
Start redis:
$ redis-server
Start a worker:
$ QUEUE=* VERBOSE=1 bundle exec rake environment resque:work
Advanced Setup
If you don’t want to populate your DB with seed data, want to manage creation of the database yourself, or otherwise manually do database setup, run any of the following commands as desired instead of rake db:setup
:
$ bundle exec rake db:create # Connects to Postgres and creates a new database
$ bundle exec rake db:schema:load # Populates the database with the current schema
$ bundle exec rake db:seed # Adds an admin user and sample data
If you skip rake db:seed
, you’ll still need to create an Admin user. You should not do this through the database since the password will need to be properly encrypted. Instead, open the rails console with rails console
and run the following:
User.create(
email: '[your email address]',
password: '[the password you want]',
admin: true,
confirmed_at: Time.now
)
License & Copyright
Copyright (C) 2017 Environmental Data and Governance Initiative (EDGI)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.0.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the LICENSE
file for details.