This is an api that was made in under 48 hours as a challenge. It takes olympic data from the 2016 summer games as a csv file and serves endpoints for seeing all events, olympians, and medalists. I focused on reducing loading times by both eager loading, and utilizing a rake task to create easily loadable associations.
https://sheltered-mesa-39586.herokuapp.com
- Clone repo
cd koroibos
bundle install
rails db:{create,migrate,seed}
bundle exec rake import:csv
rails server
- Navigate to http://localhost:3000
Returns all olympians
Headers:
Content-Type: application/json
Accept: application/json
Optional Params:
age=youngest
age=oldest
Response:
{
"olympians":
[
{
"name": "Maha Abdalsalam",
"team": "Egypt",
"age": 18,
"sport": "Diving",
"total_medals_won": 0
},
{
"name": "Ahmad Abughaush",
"team": "Jordan",
"age": 20,
"sport": "Taekwondo",
"total_medals_won": 1
},
{...}
]
}
Returns statistics for all olympians
Headers:
Content-Type: application/json
Accept: application/json
Response:
{
"olympian_stats": {
"total_competing_olympians": 3120,
"average_weight": {
"unit": "kg",
"male_olympians": 75.4,
"female_olympians": 70.2
},
"average_age": 26.2
}
}
Returns a list of events for each sport
Headers:
Content-Type: application/json
Accept: application/json
Response:
{
"events":
[
{
"sport": "Archery",
"events": [
"Archery Men's Individual",
"Archery Men's Team",
"Archery Women's Individual",
"Archery Women's Team"
]
},
{
"sport": "Badminton",
"events": [
"Badminton Men's Doubles",
"Badminton Men's Singles",
"Badminton Women's Doubles",
"Badminton Women's Singles",
"Badminton Mixed Doubles"
]
},
{...}
]
}
Returns a list of medalists for an event
Headers:
Content-Type: application/json
Accept: application/json
Response:
{
"event": "Badminton Mixed Doubles",
"medalists": [
{
"name": "Tontowi Ahmad",
"team": "Indonesia-1",
"age": 29,
"medal": "Gold"
},
{
"name": "Chan Peng Soon",
"team": "Malaysia",
"age": 28,
"medal": "Silver"
}
]
}
The sample data used is incomplete and does not include all medals for events
- RSpec
- Shoulda-Matchers
Models:
bundle exec rspec spec/models
Requests:
bundle exec rspec spec/requests
- Fork
- Make Changes
- Make Descriptive Pull Request