Giter Club home page Giter Club logo

koroibos's Introduction

Koroibos

This project is the Turing Mod 4 final project. This is a 48 hour code challenge and will be evaluated based on everything we've learned so far, including documentation, processes, and the actual code.

Because this project is a representation of everything we've learned so far, I've opted to complete it in Rails. I feel that documentation and process are important and if I were to have attempted this in a different language it would be functionally complete but weak in the other areas.

Project is deployed at https://vast-inlet-82463.herokuapp.com/

Running this application

  • Clone down repo: git clone [email protected]:Matt-Weiss/Koroibos.git
  • Install dependencies: bundle install
  • Create database: rails db:{create,migrate,seed}
  • Run local server: rails s
  • Tests can be run with: bundle exec rspec

Database schema

Imgur

Endpoints

GET /api/v1/olympians

This endpoint allows us to get all athletes along with some information about their event history, including their primary sport and their medal count.

Edge cases- Olympians have been created in the database from raw data that has some inconsistencies. If any property on the athlete has differences between entries in that data, they get an additional entry into our DB. The reason for this is that there is a chance that these are deliberate and they should be logged as a different participant.

In the future, this could be built out so that each athlete (by name) could have many attributes entries. This would require a schema change and a v2 for our api, as well as introduce the need to add additional filters so that athletes that share a name can still be distinguished from one another. I feel the current solution is the best with the data we have.

Sample return:

{
"olympians": [
  {
    "name": "Andreea Aanei",
    "team": "Romania",
    "age": 22,
    "sport": "Weightlifting",
    "total_medals_won": 0
  },
  {
    "name": "Nstor Abad Sanjun",
    "team": "Spain",
    "age": 23,
    "sport": "Gymnastics",
    "total_medals_won": 0
  },
  {...}
  ]
}

Update: Have added the ability to find the youngest and oldest athletes. Simply append ?age=youngest or ?age=oldest as a param on the end of the URI.

GET api/v1/olympian_stats

This endpoint retrieves some aggregate stats for all olympians.

Again I would like to use future time to expand on this functionality to allow for querying things like "number of teams represented" or "average height". These wouldn't be a heavy lift.

Another feature I'd like to add is the ability to change between metric and imperial units.

Sample response:

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

GET api/v1/events

This endpoint returns a list of all events sorted by the sport that they are associated with.

This query turned out to be an n^2 which I am not thrilled about, however, I do think that in this situation it's ok, as even if this application is scaled for future olympic games, it will take a very long for the event and sport lists to grow to a point that this query is untenable.

Sample response:

{
"events": [
  {
    "sport": "Archery",
    "events": [
      "Archery Women's Individual",
      "Archery Women's Team",
      "Archery Men's Individual",
      "Archery Men's Team"
    ]
  },
  {
    "sport": "Gymnastics",
    "events": [
      "Gymnastics Men's Individual All-Around",
      "Gymnastics Men's Floor Exercise",
      "Gymnastics Men's Parallel Bars",
      "Gymnastics Men's Horizontal Bar",
      "Gymnastics Men's Rings",
      "Gymnastics Men's Pommelled Horse",
      "Gymnastics Men's Team All-Around",
      "Gymnastics Men's Horse Vault",
      "Gymnastics Women's Team All-Around",
      "Gymnastics Women's Uneven Bars",
      "Gymnastics Women's Balance Beam",
      "Gymnastics Women's Individual All-Around",
      "Gymnastics Women's Floor Exercise",
      "Gymnastics Women's Horse Vault"
    ]
  },
  {...}
]
}

GET api/v1/events/:id/medalists

This endpoint returns a list of olympians that earned a medal in the specified event. The seed data set is incomplete, so some events currently show no medalists. Also of note is that there can in fact be multiples of each type of medal for an event, if that event is team based.

Sample response (event 9):

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

GET api/v1/team_medals

This endpoint returns all teams with the count of how many medals olympians.

The caveat to this endpoint is that for team sports, every member of the team contributes to the medal count.

Sample response:

{
  "team_medals": {
    "United States": 76,
    "Great Britain": 40,
    "Italy": 29,
    "Australia": 29,
    "Russia": 28,
    "Germany": 24,
    "France": 23,
    "China": 19,
    "Canada": 18,
    "Spain": 14,
    "Serbia": 13,
    "New Zealand": 12,
    "Netherlands": 10,
    "Jamaica": 10,
    ...
  }
}

GET api/v1/events_participants

This endpoint returns all events with an array of all participants in each event.

Sample response:

[
  {
    "event": "Weightlifting Women's Super-Heavyweight",
    "olympians": [
      {
        "id": 2823,
        "name": "Yaniuska Isabel Espinosa",
        "sex": "F",
        "age": 29,
        "height": 172,
        "weight": 114,
        "team": "Venezuela",
        "created_at": "2019-07-29T18:07:10.619Z",
        "updated_at": "2019-07-29T18:07:10.619Z"
      },
      {
        "id": 2380,
        "name": "Yosra Dhieb",
        "sex": "F",
        "age": 20,
        "height": 178,
        "weight": 123,
        "team": "Tunisia",
        "created_at": "2019-07-29T18:07:06.792Z",
        "updated_at": "2019-07-29T18:07:06.792Z"
      },
      {...}
    ]
  },
  {
    "event": "Gymnastics Men's Individual All-Around",
    "olympians": [
      {
        "id": 2669,
        "name": "Ludovico Edalli",
        "sex": "M",
        "age": 22,
        "height": 165,
        "weight": 57,
        "team": "Italy",
        "created_at": "2019-07-29T18:07:09.349Z",
        "updated_at": "2019-07-29T18:07:09.349Z"
      },
      {...}
    ]
  }
]

koroibos's People

Contributors

matt-weiss avatar

Watchers

James Cloos avatar  avatar

koroibos's Issues

GET api/v1/events_participants

This endpoint returns all events with an array of all participants in each event.

Sample response:

[
  {
    "event": "Weightlifting Women's Super-Heavyweight",
    "olympians": [
      {
        "id": 2823,
        "name": "Yaniuska Isabel Espinosa",
        "sex": "F",
        "age": 29,
        "height": 172,
        "weight": 114,
        "team": "Venezuela",
        "created_at": "2019-07-29T18:07:10.619Z",
        "updated_at": "2019-07-29T18:07:10.619Z"
      },
      {
        "id": 2380,
        "name": "Yosra Dhieb",
        "sex": "F",
        "age": 20,
        "height": 178,
        "weight": 123,
        "team": "Tunisia",
        "created_at": "2019-07-29T18:07:06.792Z",
        "updated_at": "2019-07-29T18:07:06.792Z"
      },
      {...}
    ]
  },
  {
    "event": "Gymnastics Men's Individual All-Around",
    "olympians": [
      {
        "id": 2669,
        "name": "Ludovico Edalli",
        "sex": "M",
        "age": 22,
        "height": 165,
        "weight": 57,
        "team": "Italy",
        "created_at": "2019-07-29T18:07:09.349Z",
        "updated_at": "2019-07-29T18:07:09.349Z"
      },
      {...}
    ]
  }
]

Create serializer for olympians

The olympians route will be pulling information from all 3 tables. the output will need to be serialized into the format in issue #8

GET api/v1/olympian_stats

Create route for display of olympian stats.

response should look like:

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

GET api/v1/events

Add route for events. Return should look like:

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

Add ability to filter olympians by age params

GET api/v1/olympians?age=youngest

should return the youngest athlete with the same serialization as all olympians

GET api/v1/olympians?age=oldest

should conversely return the oldest athlete

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

GET events/:id/medalists

This will require us to fetch events and all olympians who earned a medal, as well as what that medal was.

Will look like:

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

Make olympian params more flexible

I'd like for olympians to be able to sort by params other than simply finding the oldest or youngest.

Being able to sort by any param, as well as define the limit on the return would be ideal.

GET api/v1/olympians

This will create the GET api/v1/olympians route. Return will look like:

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

Create events serializer

Events will require us to get all events for a particular sport and aggregate the events into an array.

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.