- Install Rails (current rails version on Sriram's PC is Rails 4.2.5). Current Ruby version on Sriram's PC is 2.2.3. Installation instructions can be found at http://installrails.com/ [DO NOT USE A CLOUD VERSION]. Warning: I did not install Rails this way 1 year ago, so be prepared for perhaps a difficult install. Note that the current version of rails is Rails 5, but we're still using Rails 4.
- (Ignore this step - Disabled Postgres for production) If running in production, set up Postgres. Otherwise, SQLITE will be used. Recommend yall to just use SQLITE for now.
- Clone this repository to your computer
- Run
bundle install
to install all prerequisite "gems" (packages) - Run
bundle exec rake db:create
to create the required database - Run
bundle exec rake db:migrate
to update the database to the current schema - Run
bundle exec rake tvm:import_participants_tsv
to import participants frommaster.tsv
file for TVM 2017. If you want to reset your database - aka drop all tables and data and re-migrate the schema, runbundle exec rake db:reset
. (OLD: Runbundle exec rake csv:import_participants
to use theparticipants.csv
file from last year to populate the development database.) - (IGNORE THIS STEP: Disabled Postgres for production) If you're using postgres, set up the connection to it by creating an "application.yml" file under config/. This is a slightly involved process as you need to create certain postgres users, set the correct permissions etcs. Recommend that you stick to SQLITE unless you have the time to figure this out.
- Running
rails -s
will open the development rails server (WEBRick), you can view the application at the endpoint shown in the console - Run all the tests with
bundle exec rake test
and all tests should be passing. - Ensure that all tests pass before you make any changes
- If you want to use the legit server: use
unicorn
. To run the exact start script for unicorn in production using the production config: use./start.sh.
For development environment purposes, just enterunicorn
in the command line, this is basically a replacement forrails s
. - You may want to set up NGINX as a reverse proxy to forward requests from port 80 to the Rails unicorn socket. I used a DigitalOcean tutorial to figure this out.
- Create a feature branch (e.g. add-new-stuff)
- Check that all tests pass
- Commit to that branch
- Push to Github and make a pull request.
Participants are now in one of 6 categories, and their timing is only relevant within their individual categories:
- Couple + NUS (CN)
- Female + NUS (FN)
- Men + NUS (MN)
- Men + Open (MO)
- Team + NUS (TN)
- Women + Open (WO)
A couple is made of two members, and the couple's final time is the sum of their individual timings. A team is made of some number of members with their final time also as the sum of their individual timings. Anyone else has their timings unchanged (still individual timings).
The important change is that there now are 6 "sub-competitions" within TVM, each with their own set of timings that do not cross-compete.
- Every single person is part of a logical team.
- An individual participant is in a team with only one member, themselves.
- A couple is defined as a team with 2 members.
- A team as registered in TVM is just a team with > 2 members but this is generally irrelevant.
- Any "team timings" are computed as sum of timings of team members. Therefore timings for individuals are unchanged since it's a sum with only one operand.
- This means that a simple table can be created called "teams". A team has a one-to-many relationship with participant. This causes minimal changes to the overall structure of the codebase since participant directly does not need to have knowledge of what team they are in - as this can be computed at import-time.
- Create a "Team" model. Team has_many Participants, Participant belongs_to Team. Team also has a string field: category.
- Add regex validation for the specific type of bib number being used