项目作者: aneksamun

项目描述 :
API for determining teams standings within Premier League Table
高级语言: Scala
项目地址: git://github.com/aneksamun/premier-league-api.git
创建时间: 2018-10-04T18:22:49Z
项目社区:https://github.com/aneksamun/premier-league-api

开源协议:

下载


Premier League API

An API for determining teams standings within Premier League Table.

Endpoints

Path Method Response Details
/games POST 201/400 Stores a football match to the database
/games/:week GET 200 Retrieves game results for given week
/table GET 200 Calculates team standings

To save a football match data must be present in following format:

  1. {
  2. "gameWeek": 1,
  3. "homeTeam": "Arsenal",
  4. "awayTeam": "Leicester",
  5. "homeGoals": 2,
  6. "awayGoals": 1
  7. }

The game week suppose to be between 1 and 38.

The game resuts are ordered alphabetically by home team. If not games have been POSTed for a specified game week, an empty array is returned.

  1. [
  2. {
  3. "homeTeam": "Arsenal",
  4. "awayTeam": "Leicester",
  5. "homeGoals": 2,
  6. "awayGoals": 1,
  7. "result": "Home Win"
  8. }
  9. ]

The table is paged therefore offset and limit can be included in query string, for example, localhost:9000\table?offset=1&limit=10. Default values is 1 for offset and 20 for limit.
The teams gets awarded with 3 points winning a game and with 1 point for draw.

  1. {
  2. "offset": 1,
  3. "limit": 2,
  4. "total": 2,
  5. "items": [
  6. {
  7. "position": 1,
  8. "team": "Arsenal",
  9. "gamesPlayed": 1,
  10. "gamesWon": 1,
  11. "gamesDrawn": 0,
  12. "gamesLost": 0,
  13. "goalsFor": 2,
  14. "goalsAgainst": 1,
  15. "goalDifference": 1,
  16. "points": 3
  17. },
  18. {
  19. "position": 2,
  20. "team": "Leicester",
  21. "gamesPlayed": 1,
  22. "gamesWon": 0,
  23. "gamesDrawn": 0,
  24. "gamesLost": 1,
  25. "goalsFor": 1,
  26. "goalsAgainst": 2,
  27. "goalDifference": -1,
  28. "points": 0
  29. }
  30. ]
  31. }

Build instructions

  • Compile
    1. sbt compile
  • Build deployable binary
    1. sbt dist
  • Build a Docker image
    1. sbt docker:publishLocal
  • Run application and dependencies
    1. docker-compose up -d

Web interface

Premier League Table
table
No content page
nothing
Error page
error