Closed joshvince closed 7 years ago
OK, this is updated:
Every 5 minutes, this app calls the TFL API and requests the status of the northern line.
When the client hits the /lines/northern
endpoint, the app returns a "score", which is calculated with some simple maths that treats delays/closure responses from TFL as high/bad and good service responses from TFL as low/good. The score can be considered a rough guide as to how the line has performed in the last hour.
This is ready for the front end work to begin now. I'll do that in another branch.
This creates a whole bunch of functionality and scaffolding:
npm run reset-db
)And, in terms of getting actual Tube Statuses:
/lines/northern
endpoint.scoreArray
value in the record like this: 1: Add the latest status code to the front of the array 2: Remove the last (oldest) entry in the array if there's already 12 entriesThe scoreArray is currently returned to the client. In the next round, the app will call the TFL api and update the internal DB at regular intervals (every 5 mins). Then, when the client calls the
/lines/northern
endpoint, the client will receive a "Score", which will be some jiggery pokery maths to do with whether there has been any delays on the line in the last hour (12 entries in the array, remember).