A REST interface for UW Madison course data, powered by Rails. This README is for setting up your own Madgrades API and is not designed to help you navigate the website.
Prerequisites:
- Ruby 2.5+, and bundler gem
- Elasticsearch 5+ @
localhost:9200
gem install bundler
- Setup the
config/database.yml
file to point to a working database. - Run migrations:
rake db:create && rake db:migrate
- Test it out:
rails s
and visithttp://localhost:3000
- Populate the database with real data (see below)
- Setup API authentication (see below)
- Setup Elasticsearch with
rake reindex
The data for the API should be populated from an external source. The madgrades project exports tables in SQL dump format which can imported easily into this API using the following command (assuming MySQL database, which is the default, but others would likely work too):
$ cat *.sql | mysql -p -u <username> madgrades_dev
This can take a long time (5+ minutes, longer on slower computers). Alternatively, you can export the data to CSV files and import using tools/methods that you prefer.
Note: In order to import large SQL dumps, you may have to tune up your SQL server settings or else you may get an error like:
MySQL server has gone away
. Setmax_allowed_packet = 1G
temporarily in yourmysqld.conf
ormy.cnf
depending on your operating system. It is dangerous to keep this setting, so revert it back to ~16M once imported.
Once imported, from the Rails API use rake grades
to populate necessary the grade distribution tables.
You will notice that inside config/initializers/omniauth.rb
there is a GitHub auth provider.
You must create your own developer application on the GitHub platform and put it in your
environment variables before executing the app. When creating your application,
it is only important that your callback is listed as:
- Github:
http://localhost:3000/auth/github/callback
If you are not running on localhost:3000
, make sure you reflect that in your GitHub app.