GithubHelp home page GithubHelp logo

briggysmalls / late-train-mate Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 6.73 MB

A lightweight website that provides stats on delayed or cancelled UK train services

License: MIT License

HTML 12.87% CSS 2.03% JavaScript 2.44% TypeScript 82.66%

late-train-mate's Introduction

Hi there ๐Ÿ‘‹

I'm Sam, just another nerd.

I really enjoy tinkering with software. You can see some discussion at my neglected blog: sambriggs.dev.

I get a real kick out of someone opening a PR on one of my projects, so don't be shy!

Sam's GitHub stats

Top Langs

late-train-mate's People

Contributors

artemzi avatar briggysmalls avatar douglas-vaz avatar gilhanan avatar hsbakshi avatar marc-portier avatar mkonars avatar vladotesanovic avatar

Watchers

 avatar  avatar

late-train-mate's Issues

Failed HSP API requests are not handled

When attempting to access the HSP API with incorrect credentials, the HTTP status code is 503 (authorisation failed).
This causes the results process to fail and the web page appear to be loading results indefinitely.
HTTP status codes other than 200 (OK) should pass a message to the front end/terminate gracefully.

Gunicorn worker timeout for long searches

Searching for late trains over a long period means that the results SSE connection is open for a long time (many services to search). Once this connection is open for 30 seconds the following log message is observed:

[2017-01-09 22:46:44 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:10)

This leads to the thread being aborted. The connection is reopened by the client and the cycle repeats.
This bug should be resolved so that the same connection is permitted to be open for longer.

Stations appear multiple times

The suggested stations in the search typeahead contains duplicates. e.g. London Victoria and London Waterloo appear multiple times.

Add about page

There should be an about page that bigs me up, links to this repo and credits National Rail

Results need sorting

Currently results are displayed in the order they arrive.
As the HSP API returns results per service, this means they are ordered by time of day.
It would be more helpful for results to be ordered by date.
Certainly some sort of ordering should be implemented, so that parallelism could be introduced in the future.

Remove weekdays/saturday/sunday option on search

Currently the search form is tightly coupled to the HSP API parameters: from/to station, from/to date, day, tolerance.

However from a user perspective, it should be sufficient to specify a date range and the app handle the rest.

The form should be updated to make three requests if necessary: WEEKDAYS, SATURDAY and SUNDAY, should the date range span these days.

Add validators to search form

The reactive form on the search page currently has no error checking /validators.

The user should not be able to submit with errors in the form, and should be prompted with some hints on how to fix any issues.

Station not found

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.

Use ngrx/store

The starter theme uses ngrx/store for maintaining state across the application.

This seems to be the grown-up way for preserving data and keeping things testable.

Whilst there is less need for it here (we don't need to pass data between components) the testability argument stands. It might well be more efficient for Angular to pick up DOM changes too...

Handle cancellations intelligently

A cancelled train means that a passenger must have taken the next train service to reach their destination.
It would be good to determine a delay based upon the scheduled arrival of the cancelled service and the actual arrival of the next service.

Metric/stat mismatch! reported

The trains.py source code is sometimes triggering the assertion:

File "/Users/sambriggs/Code/Python/late-train-mate/late_train_mate/trains/trains.py", line 247, in _delays_in_service
    "Metric/stat mismatch!")
AssertionError: Metric/stat mismatch!

This bug should be eliminated

Select box for stations

Currently the user types the to and from locations into a StringField.
As there is a finite list of valid station 3 letter codes, these fields should instead be a SelectField.
Currently invalid values are not detected and an HTTP POST failure to the HSP API occurs.
It would also be good to use a plugin such as Chosen to make the selection nicer for the user.

Breaks for looping routes

When searching for delays from Dover Priory to London St. Pancras International the app fails an assertion. This is due to the assumption that each station will only appear once in the list of journey stops.

However some routes have London St. Pancras International as the first and last stop, meaning that the incorrect (first) stop is selected.

The app should be updated to handle looping route where a station may appear multiple times.

Add slider for delay

All delays are now displayed which usually results in a large number of responses that are not of much interest.

The intention was to add a slider that could be used to filter the displayed options. This should be added.

Expose more config in Heroku

Currently the National Rail Data Feeds credentials are obtained from Heroku environment variables while running Heroku.
Further settings such as the flask secret key and debug mode etc. might be exposed here too.
If so it might make sense to refactor config.yaml so that there is a group of publicly exposed settings.
Perhaps the relevant to code to read these settings, and app.json could be generated from config.yaml

Show full leg details

Currently the journey info modal dialog displays the to/from stations and their scheduled/actual times.

Instead the arrival? departure? times should be displayed for all the stations on the route. Furthermore the colour of the stops should be set based upon on-time/delayed/cancelled status at that particular stop.

Improve versioning

The project should employ the use of semantic versioning. This should see config.yaml updated with individual Major, minor, patch version numbers.
Furthermore it would probably be beneficial to have a fourth, informational build number.
The SemVer 2.0 specification says this would like like:
<Major>.<minor>.<patch>+<build>
As per this answer
We would probably get the build number from git using Git Hooks

Typeable stations

Search form should allow for typing stations and offering suggestions

Consider licence

Currently still uses MIT licence as per starter project. Consider LGPL?

Use station text not value on results page

Currently the results page displays a summary of the search form parameters.

This displays the to/from stations using their codes not display text.

The summary should be updated to use the human readable text.

Use a frontend framework

Currently results are send from the server to the client.
These results are handled by JavaScript and pushed into the DOM.

For more complex behaviour, such as #3 or even just rearranging results as #13 some sort of MVC framework would be preferred. I.e. results being held in a JavaScript object representing the model and the view reflecting the state of the model.

Fix lint errors

The starter project nicely set up a linter...which is having a heart attack over the current state of the repo ๐Ÿ–ค

Cache responses

As historic train data is never going to chance, it makes sense to cache recent responses from the HSP API.

Show previous results if user presses 'back'

Currently if the user leaves the results page and return via the 'back' button the queries are run again.

However all of the information is already loaded so it would be nice if it was re-displayed

Remove resourceService dependency from model

Currently the MetricsCollection/Metrics/JourneyDetails model classes all have a dependency on the ResourceService.

This is mainly in order to convert station codes to Station objects, allow handy lookup of their human readable name.

However it appears Angular's opinion is that dependency-injected objects belong in the Angular world and shouldn't be passed down into pure classes.

Consider removing this dependency, as it mainly just functions as a method to obtain human readable information from codes.

Review app structure

At the moment the application has a flat file structure. It also has flat imports that mirror this structure. This is getting pretty unwieldy

You should consider grouping components together, e.g. ResultsComponent and LegComponent (given one appears within the other) into separate directories using a Feature Module much like the current app.module.ts file.

Parallelise service details requests

Having to make a new ServiceDetails request for every single service results in slow work.
It would be good to parallelise the requests for details to some degree.

Setup CI

Travis should be set up to run the karma test suites developed in #16.

However there is no reason not to get an empty test suite passing, thereby at least checking for compilation errors.

It should also run linting.

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.