Skip to content

Files

Latest commit

 

History

History
 
 

election-api-scala

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Description

If you are not familiar with how elections work in the UK, please see this short BBC video https://www.youtube.com/watch?v=cRxUhGetEPQ

The results API presents a simple elections result service.

Domain

The domain for the election represents some key concepts:

  • constituencyId a unique integer id to identify a location. E.g "Brent Central" is 90
  • party is a short 3, or 4, letter code for a party for instance LAB = Labour, CON = Conservative etc.
  • votes the number of votes gained by a party in a constituency
  • share the % share of the total votes the party received

API

The API has 3 endpoints:

  • GET /result/{id} to get an elections result for a given id.
  • POST /result to add a new result
  • GET /scoreboard to get the running totals. This is unimplemented.

Task

During your assessment we will ask you to work though the task in tasks.md with a pair. Please do not work on or complete these prior to the assessment.

Warning: If you make any changes to the code, please ensure you return it to its initial (HEAD) state before your assessment.

Prerequisites

  • Java 11
  • Scala
  • sbt

To Build

sbt compile

To Run

sbt run

You may get a port error when you try to run this. If so, run the following command:

export PLAY_HTTP_PORT=9001

To Test

sbt test