Giter Club home page Giter Club logo

koroibos's Introduction

Project: Quantified Self

Visit the app on Heroku:

https://serene-reaches-07094.herokuapp.com/

Contributors

About the Project

  • Koroibos was a solo project completed within a 48-hour timeframe to mock a technical take home challenge
  • The purpose was to build a tested RESTful API with Olympian data imported from a CSV that exposes 6 endpoints that analyzes the data

Tech Stack

  • Ruby on Rails
  • ActiveRecord
  • PostgreSQL

Packages Used

  • Fast JSON API
  • RSpec
  • SimpleCOV

Database Diagram

schema

Local Setup

Instructions:

  1. Clone the GitHub repository
  2. Go to the directory with the new repo
  3. Run bundle install
  4. Setup database: a) Run rails db:{create,migrate} b) Import data with rails import:csv
  5. To run the server: rails s

Run tests:

  1. Run rspec
  2. To run a single test file: rspec <test directory>
  3. To generate coverage report: open coverage/index.html

Endpoints

Olympian Endpoints:

1) User can get all Olympians

Request:

GET /api/v1/olympians

Response Example:

status: 200

{
    "data": [
        {
            "id": "1",
            "type": "olympian",
            "attributes": {
                "name": "Andreea Aanei",
                "age": 22,
                "sport": "Weightlifting",
                "team": "Romania",
                "total_medals_won": 0
            }
        },
        {
            "id": "2",
            "type": "olympian",
            "attributes": {
                "name": "Nstor Abad Sanjun",
                "age": 23,
                "sport": "Gymnastics",
                "team": "Spain",
                "total_medals_won": 0
            }
        },
        {...}
    ]
}

2) User can get the youngest Olympian

Request:

GET /api/v1/olympians?age=youngest

Response Example:

status: 200

{
    "data": {
        "id": "2190",
        "type": "olympian",
        "attributes": {
            "name": "Ana Iulia Dascl",
            "age": 13,
            "sport": "Swimming",
            "team": "Romania",
            "total_medals_won": 0
        }
    }
}

3) User can get the oldest Olympian

Request:

GET /api/v1/olympians?age=oldest

Response Example:

status: 200

{
    "data": {
        "id": "1321",
        "type": "olympian",
        "attributes": {
            "name": "Julie Brougham",
            "age": 62,
            "sport": "Equestrianism",
            "team": "New Zealand",
            "total_medals_won": 0
        }
    }
}

4) User can get Olympian stats

Request:

GET /api/v1/olympian_stats

Response Example:

status: 200

{
    "data": {
        "id": null,
        "type": "olympian_stats",
        "attributes": {
            "total_competing_olympians": 2850,
            "average_weight": {
                "unit": "kg",
                "male_olympians": 77.9,
                "female_olympians": 61.4
            },
            "average_age": 26.4
        }
    }
}

Event Endpoints:

1) User can events specified to their sport

Request:

GET /api/v1/events

Response Example:

status: 200

{
    "data": [
        {
            "id": "1",
            "type": "sport",
            "attributes": {
                "name": "Weightlifting",
                "events": [
                    "Weightlifting Women's Super-Heavyweight",
                    "Weightlifting Men's Heavyweight",
                    "Weightlifting Men's Middleweight",
                    "Weightlifting Men's Middle-Heavyweight",
                    "Weightlifting Men's Featherweight",
                    "Weightlifting Women's Flyweight",
                    "Weightlifting Women's Middleweight",
                    "Weightlifting Women's Lightweight",
                    "Weightlifting Men's Lightweight",
                    "Weightlifting Men's Super-Heavyweight",
                    "Weightlifting Men's Light-Heavyweight",
                    "Weightlifting Women's Heavyweight",
                    "Weightlifting Women's Light-Heavyweight",
                    "Weightlifting Men's Bantamweight",
                    "Weightlifting Women's Featherweight"
                ]
            }
        },
        {...}
    ]
}

2) User can get a specific event's medalists

Request:

GET /api/v1/events/:id/medalists

Response Example:

status: 200

{
    "data": {
        "id": null,
        "type": "event_medalist",
        "attributes": {
            "event": "Rowing Men's Coxless Pairs",
            "medalists": [
                {
                    "name": "Giovanni Abagnale",
                    "team": "Italy",
                    "age": 21,
                    "medal": "Bronze"
                },
                {
                    "name": "Hamish Byron Bond",
                    "team": "New Zealand",
                    "age": 30,
                    "medal": "Gold"
                },
                {
                    "name": "Lawrence Brittain",
                    "team": "South Africa",
                    "age": 25,
                    "medal": "Silver"
                },
                {
                    "name": "Marco Di Costanzo",
                    "team": "Italy",
                    "age": 24,
                    "medal": "Bronze"
                }
            ]
        }
    }
}

koroibos's People

Contributors

sejinkim1904 avatar

Watchers

James Cloos avatar  avatar

koroibos's Issues

User Story 3 - User can get the oldest Olympian

As a user
When I send a GET request to '/api/v1/olympians?age=oldest'
It returns the oldest Olympian

Response:

{
  [
    {
      "name": "Julie Brougham",
      "team": "New Zealand",
      "age": 62,
      "sport": "Equestrianism"
      "total_medals_won": 0
    }
  ]
}

User Story 5 - User can get a list of events

As a user
When I send a GET request to '/api/v1/events'
It returns a list of all events including:
- sport
- events

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"
        ]
      },
      {...}
    ]
}

Build rake task to import csv

Build rake task to import CSV file into appropriate tables:

  • olympians

  • name

  • sex

  • age

  • weight

  • teams

  • name

  • sports

  • name

  • events

  • name

User Story 4 - User can get Olympian stats

As a user
When I send a GET request to '/api/v1/olympian_stats'
It returns Olympian stats including:
- total competing olympians
- average weight:
  - unit 
  - male
  - female
- average age

Response:

  {
    "olympian_stats": {
      "total_competing_olympians": 3120
      "average_weight:" {
        "unit": "kg",
        "male_olympians": 75.4,
        "female_olympians": 70.2
      }
      "average_age:" 26.2
    }
  }

User Story 1 - User can get a list of all Olympians

As a user
When I send a GET request to '/api/v1/olympians'
It returns a list of all olympians 

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
      },
      {...}
    ]
}

User Story 2 - User can get the youngest Olympian

As a user
When I send a GET request to 'api/v1/olympians?age=youngest'
It returns the Olympian with the youngest age

Response:

{
  [
    {
      "name": "Ana Iulia Dascl",
      "team": "Romania",
      "age": 13,
      "sport": "Swimming"
      "total_medals_won": 0
    }
  ]
}

User Story 6 - User can get a specific event's medalists

As a user
When I send a GET request to '/api/v1/events/:id/medalists'
It returns an event and all its medalists

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"
      }
    ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.