Skip to content

Add API to get time since last route update #312

Open

Description

@SparksDJ

On the orienteering club website I maintain, I like to annotate links to volatile pages with the date the link target was last updated. It would be useful to do this for the link from an event results page to the routegadget page for that event. This should be possible if the rg2 API supported a request which returned a text/plain result giving the last-amended time of the route data for the event, either as a string such as 2005-08-15T15:52:01+00:00 or as minutes since the last change (rounded up).

Activity

  1. Maprunner commented on Jul 1, 2016

    @Maprunner
    Owner

    I've put a prototype on www.test.routegadget.co.uk

    API is:
    www.test.routegadget.co.uk/rg2/rg2api.php?id=x&type=lastupdate

    If x is a valid event id you will get a response:

    {"data":{"updated":{"time":"2016-05-08T21:41:11+02:00","id":"1"},"API version":"1.2.7"}}

    where the last modification date is formatted as an ISO 8601 date.

    If x is not a valid event id then you will get:

    {"data":{"updated":{"time":"File not found","id":"1000"},"API version":"1.2.7"}}

    Please can you have a look and suggest any changes before I add it to the master branch.

  2. SparksDJ commented on Jul 1, 2016

    @SparksDJ
    Author

    On Fri, 2016-07-01 at 13:36 -0700, Simon Errington wrote:

    I've put a prototype on www.test.routegadget.co.uk

    That was a lot quicker than I expected!

    API is:
    www.test.routegadget.co.uk/rg2/rg2api.php?id=x&type=lastupdate

    ...

    Please can you have a look and suggest any changes before I add it to the master branch.

    id=1 and id=2 both returned the same date and time; id=999 returned
    'file not found'

    It might be useful to add a Cache-Control: header, for example

    Cache-Control: max-age=300

    which might not always have an effect, but in principle should stop the
    browser polling too quickly (max-age=300 should limit polls to once
    every five minutes) and affect what happens if the user returns to the
    page which uses the API: if the page is re-shown in less than five
    minutes, the previously returned value can be used, while if more than
    five minutes has elapsed the browser should fetch a new value.

    Dave Sparks
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions