Giter Club home page Giter Club logo

koroibos's Introduction

Koroibos Express

An API for olympics data analytics using Node.Js and Express.

Deployed Build

  • A deployed version of this application can be found here.
  • The project board for this application is located here.

Local Build

To install this project locally, follow these directions.

Requirements

  • PostgreSQL
  • NPM Version 6.11.3
  • Express Version: 4.16.1

Setup

  • Download this project into a working directory.

  • Install the requirements using npm:

npm install

This will install the required pacakges for the project.

  • Create and migrate the local database using sequelize:

npx sequelize db:create npx sequelize db:migrate

  • A Jake task has been written to input sample olympian data into the database. To use this data, run the following command:

npx jake readCSV

  • As an Express app, you are able to start the server using the following command:

npm start

Endpoints

The following endpoints are exposed on this API:

  • /api/v1/olympians
  • /api/v1/olympians?age=youngest
  • /api/v1/olympians?age=oldest
  • /api/v1/olympians?medals=most
  • /api/v1/olympians?medals=least
  • /api/v1/olympians?medals=<#>
  • /api/v1/olympian_stats
  • /api/v1/events
  • /api/v1/events/:id/medalists

/api/v1/olympians

This endpoint takes a get request. It returns a list of all Olympian athletes in the database, and an error message if no athletes are present in the database.

An example response is as follows:

{
  "olympians":
  [
    {
      "name":"Brian Richard Baker",
      "team":"United States",
      "age":31,
      "sport":"Tennis",
      "total_medals_won":"0"
    },
    {
      "name":"Inna Vasilyevna Deriglazova",
      "team":"Russia",
      "age":26,
      "sport":"Fencing",
      "total_medals_won":"1"
    },
    {...}
  ]
}

/api/v1/olympians?age=youngest

This endpoint takes a get request. It returns the youngest of all Olympian athletes in the database, and an error message if no athletes are present in the database.

An example response is as follows:

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

/api/v1/olympians?age=oldest

This endpoint takes a get request. It returns the oldest of all Olympian athletes in the database, and an error message if no athletes are present in the database.

An example response is as follows:

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

/api/v1/olympians?medals=most

This endpoint takes a get request. It returns the all Olympian athletes in the database, sorted by total number of medals won, and an error message if no athletes are present in the database. At least a single medal must be won to be included in this list.

An example response is as follows:

{
  "olympians":
    [
      {
        "name":"Simone Arianne Biles",
        "team":"United States",
        "age":19,
        "sport":"Gymnastics",
        "total_medals_won":"5"
      },
      {
        "name":"Nathan Ghar-Jun Adrian",
        "team":"United States",
        "age":27,
        "sport":"Swimming",
        "total_medals_won":"4"
      },
      {...}
    ]
  }
}

/api/v1/olympians?medals=least

This endpoint takes a get request. It returns the all Olympian athletes in the database, sorted by total number of medals won, and an error message if no athletes are present in the database. At least a single medal must be won to be included in this list.

An example response is as follows:

{
  "olympians":
    [
      {
        "name":"Ashton James Eaton",
        "team":"United States",
        "age":28,
        "sport":"Athletics",
        "total_medals_won":"1"
      },
      {
        "name":"lodie Pascaline Clouvel",
        "team":"France",
        "age":27,
        "sport":"Modern Pentathlon",
        "total_medals_won":"1"
      },
      {...}
    ]
  }
}

/api/v1/olympians?medals=<#>

This endpoint takes a get request. It returns the Olympian athletes in the database that have won the number of medals indicated in the query parameter, and an error message if no athletes are present in the database.

An example response for 5 as the query parameter is as follows:

{
  "olympians":
    [
      {
        "name":"Simone Arianne Biles",
        "team":"United States",
        "age":19,
        "sport":"Gymnastics",
        "total_medals_won":"5"
      },
    ]
  }
}

/api/v1/olympian_stats

This endpoint takes a get request. It returns statistics for all Olympian athletes in the database, showing a total count of athletes, average age of all athletes, and weight by athlete sex. An error message if no athletes are present in the database

An example response is as follows:

{
  "olympian_stats":
    {
      "total_competing_olympians":"2862",
      "average_weight":
        {
          "unit":"kg",
          "male_olympians":"79.4",
          "female_olympians":"62.7"
        },
      "average_age":"26.4"
    }
  }
}

/api/v1/events

This endpoint takes a get request. It returns all events in the database, grouped by each sport. No duplicate events will appear in this endpoint, and an error message if no events are present in the database.

An example response is as follows:

{
  "events":
    [
      {
        "sport": "Archery",
        "events": [
          "Archery Men's Individual",
          "Archery Men's Team",
          "Archery Women's Individual",
          "Archery Women's Team"
        ]
      },
      {
        "sport": "Athletics",
        "events": [
          "Athletics Men's 1,500 metres",
          "Athletics Men's 10,000 metres",
          "Athletics Men's 100 metres",
          "Athletics Men's 110 metres Hurdles",
          "Athletics Men's 20 kilometres Walk",
          ...
        ]
      },
      {...}
    ]
}

/api/v1/events/:id/medalists

This endpoint takes a get request. It returns all medalists for a particular event, dictated by the ID passed in the URL parameter, showing each athlete's name, team, age and medal won.

An example response for 119 as the ID parameter is as follows:

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

koroibos's People

Contributors

davisc0801 avatar

Watchers

James Cloos avatar

koroibos's Issues

Olympians Fewest Medal Count

GET api/v1/olympians?medals=least

  • Shows name, team, age, sport, and medals won count. Sorts the Olympians by lowest medal count. Olympians with no medals won will not be listed.
{
  [
    {
      "name": "Giovanni Abagnale",
      "team": "Italy",
      "age": 21,
      "sport": "Rowing"
      "total_medals_won": 1
    },
    {...}
  ]
}

Deployment

  • Finalize Deployment database configuration
  • Add Readme and any other API Documentation

Olympian Medal List Endpoint

GET api/v1/events/:id/medalists

  • Provides a list of all medalist names, team, age, and medal won.
{
  "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"
      }
    ]
}

Initial Setup

  • Install all NPM packages
  • Setup Testing Suites
  • Create and migrate database

Olympians Medal Count

GET api/v1/olympians?medals=most

  • Shows name, team, age, sport, and medals won count. Sorts the Olympians by medal count. Olympians with no medals won will not be listed.
{
  [
    {
      "name": "Nathan Ghar-Jun Adrian",
      "team": "United States",
      "age": 27,
      "sport": "Swimming"
      "total_medals_won": 3
    },
    {...}
  ]
}

Olympian Stats Endpoint

GET api/v1/olympian_stats

  • Shows total count, average weight by gender and average age.
{
    "olympian_stats": {
      "total_competing_olympians": 3120
      "average_weight:" {
        "unit": "kg",
        "male_olympians": 75.4,
        "female_olympians": 70.2
      }
      "average_age:" 26.2
    }
  }

Olympians Index Endpoint

GET api/v1/olympians

  • Index page of all entries, only contains name, team, age, sport, and medals won count.
    [
      {
        "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
      },
      {...}
    ]

Olympian Events Endpoint

GET api/v1/events

  • Shows a list of all event names as strings under a specific sport.
{
  "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"
        ]
      },
      {...}
    ]
}

Oldest Age Endpoint

GET api/v1/olympians?age=oldest

  • Shows name, team, age, sport, and medals won count.
{
  [
    {
      "name": "Julie Brougham",
      "team": "New Zealand",
      "age": 62,
      "sport": "Equestrianism"
      "total_medals_won": 0
    }
  ]
}

Youngest Age Endpoint

GET api/v1/olympians?age=youngest

  • Shows name, team, age, sport, and medals won count.
{
  [
    {
      "name": "Ana Iulia Dascl",
      "team": "Romania",
      "age": 13,
      "sport": "Swimming"
      "total_medals_won": 0
    }
  ]
}

Testing

  • Test all endpoints using Jest.
  • Include sad path testing where applicable.

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.