GithubHelp home page GithubHelp logo

koroibos's Introduction

Koroibos Challenge

This is a Node Express api built to expose data from the 2016 Summer Olympics. It was issued as a 48 hour take home challenge by Turing School of Software and Design as the final module solo project.

Status: Refactor

Getting Started

For Developers: Testing

  • For testing I used Jest with the following dependencies:
"babel-jest": "^24.9.0",
"jest": "^24.9.0",
"shelljs": "^0.8.3",
"supertest": "^4.0.2"
  • To run tests:
$ knex migrate:latest --env test
$ npm test
  • Clone down the repo and run the following commands:

database

  1. Create the database, run this in the CLI with psql installed:
$ psql
$ create database olympians;
$\q
  1. We need to run the migrations to create the olympians table to store the data:
$ npm install
$ knex migrate:latest

You want to make sure your database gets populated properly, run the following commands in CLI:

$ psql
$ \c olympians
$ \copy olympians (name,sex,age,height,weight,team,games,sport,event,medal) FROM 'data.csv' WITH DELIMITER ',' CSV HEADER;
$select * from olympians; 

Your olympians table should now be populated, below is the schema output from our migration:

Schema

Screen Shot 2020-01-15 at 7 57 08 AM

Endpoints

  1. Getting all olympians:
GET api/v1/olympians
//Response Format
{
  "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
      },
      {...}
    ]
}
  1. Getting the youngest olympian:
GET api/v1/olympians?age=youngest
//Response Format
{
  [
    {
      "name": "Ana Iulia Dascl",
      "team": "Romania",
      "age": 13,
      "sport": "Swimming"
      "total_medals_won": 0
    }
  ]
}

3.Getting the oldest olympian:

GET api/v1/olympians?age=oldest
//Response Format
{
  [
    {
      "name": "Julie Brougham",
      "team": "New Zealand",
      "age": 62,
      "sport": "Equestrianism"
      "total_medals_won": 0
    }
  ]
}
  1. Getting olympian statistics:
GET api/v1/olympian_stats
//Response format
  {
    "olympian_stats": {
      "total_competing_olympians": 3120
      "average_weight:" {
        "unit": "kg",
        "male_olympians": 75.4,
        "female_olympians": 70.2
      }
      "average_age:" 26.2
    }
  }
  1. Getting olympian events:
GET api/v1/events
//Response Format
{
  "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"
        ]
      },
      {...}
    ]
}

Core contriutor

  • Scott Payton git: scottzero

koroibos's People

Contributors

scottzero avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Forkers

timothywu1

koroibos's Issues

User Story 3: GET api/v1/olympians?age=oldest

As a user I should be able to get the oldest user data when I hit this endpoint:
GET api/v1/olympians?age=oldest

My response should be:

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

User Story 2: GET api/v1/olympians?age=youngest

As a user I should be able to get the youngest olympian data,
when I hit end point
GET api/v1/olympians?age=youngest

My response should be

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

User Story 1: GET api/v1/olympians

As a user I should be able to GET all olympians in the database.
When I hit this endpoint
GET api/v1/olympians
my 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 5: GET api/v1/events

As a user I should be able to get olympic events when I hit this endpoint
GET api/v1/events

and my response should be:

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

User Story 4: GET api/v1/olympian_stats

As A user I should be able to get olympian stats
when I hit the endpoint GET api/v1/olympian_stats
and my response should be:

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

User Story 6: GET api/v1/events/:id/medalists

As a user I should be able to get medalists for a specific event when I hit this endpoint:
GET api/v1/events/:id/medalists
and my response look like this:

{
  "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.