briggySmalls / late-train-mate

A lightweight website that provides stats on delayed or cancelled UK train services
MIT License
0 stars 0 forks source link

Station not found #20

Closed briggySmalls closed 6 years ago

briggySmalls commented 6 years ago

When searching for journeys on the Finsbury Park - Cambridge service the initial response is returned and the following error is thrown during the handling:

Error: InvalidOperationException: The source sequence is empty.
    at List.webpackJsonp.../../../../linqts/dist/linq.js.List.First (linq.js:139)
    at List.webpackJsonp.../../../../linqts/dist/linq.js.List.First (linq.js:136)
    at ResourceService.webpackJsonp.../../../../../src/app/national_rail/resource.service.ts.ResourceService.lookup (resource.service.ts:22)
    at new ServiceAttributes (hsp-types.ts:125)
    at new ServiceMetrics (hsp-types.ts:102)
    at hsp-types.ts:70
    at Array.map (<anonymous>)
    at new MetricsCollection (hsp-types.ts:69)
    at Function.<anonymous> (hsp-api.service.ts:34)
    at MapSubscriber.webpackJsonp.../../../../rxjs/operator/map.js.MapSubscriber._next (map.js:77)

Somehow a station code is used in the ResourceService that is not found in the csv.

briggySmalls commented 6 years ago

This is probably the new Cambridge North station! The station list should be constructed from reference data that is updated regularly. This is probably using the KnowledgeBase XMLs API.

For example the file can be downloaded simply:

curl -H "Accept: */*" -H "Content Type: application/xml" -H "X-Auth-Token: <TOKEN>" https://datafeeds.nationalrail.co.uk/api/staticfeeds/4.0/stations > station-codes.xml

Where <TOKEN> is a token obtained by authenticating at https://datafeeds.nationalrail.co.uk/authenticate as described on the wiki

briggySmalls commented 6 years ago

Note: Can make use of the Last-Modified header to check if the stations list has updated

briggySmalls commented 6 years ago

Fixed for now in f77ef400718b32cd025f9aea56397a530973897a but issue created for automatically scheduling downloads to update resources list #24