Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RPDE implementation #141

Closed
nickevansuk opened this issue Jun 19, 2018 · 16 comments
Closed

Fix RPDE implementation #141

nickevansuk opened this issue Jun 19, 2018 · 16 comments

Comments

@nickevansuk
Copy link
Contributor

nickevansuk commented Jun 19, 2018

Applying rules:

Please do check the underlying query is being implemented correctly: https://www.openactive.io/realtime-paged-data-exchange/#sql-query-example-for-timestamp-id:

  --include WHERE clause only if @afterTimestamp and @afterId provided
      WHERE (modified = @afterTimestamp
               AND id > @afterId)
         OR (modified > @afterTimestamp)
   ORDER BY modified,
            id

Not like this:

{
  "next": "http://api.letsride.co.uk/public/v1/rides?from=1970-01-01+01%3A02%3A10",
  "items": [
    {
      "state": "updated",
      "id": 2710,
      "kind": "event",
      "modified": "1970-01-01 01:00:01"
      "data": {}
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}

Like this:

{
  "next": "http://api.letsride.co.uk/public/v1/rides?afterTimestamp=1453931925&afterId=2710",
  "items": [
    {
      "state": "updated",
      "id": 2710,
      "kind": "event",
      "modified": 1453931925,
      "data": {}
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}

Note that the next URL must include the id and the modified values from the last item in the current page (see here for more details: https://www.openactive.io/realtime-paged-data-exchange/#modified-timestamp-and-id)

@sevenpointsix
Copy link
Collaborator

This should be ready for testing at http://lr-api.staging.phoenixdigital.agency/public/v1/rides/

@sevenpointsix sevenpointsix moved this from In progress to QA in British Cycling Endpoint Review Aug 5, 2018
@nickevansuk
Copy link
Contributor Author

nickevansuk commented Aug 7, 2018

Just looking at these pages, in order:

Note that the ORDER BY modified, id means that afterTimestamp should be increasing, which they are not.

Also the second page of the feed returns "No ride data found".

And this page returns an error.

These indicate that the query has not been implemented correctly. Please check:

  --include WHERE clause only if @afterTimestamp and @afterId provided
      WHERE (modified = @afterTimestamp
               AND id > @afterId)
         OR (modified > @afterTimestamp)
   ORDER BY modified,
            id

@nickevansuk
Copy link
Contributor Author

This is much better! However on this page the next URL doesn't appear to have an afterTimestamp which is greater than the current value, which suggests the query might still be wrong.

There's now a helpful video on this page which might be useful (any feedback welcome!)

@sevenpointsix
Copy link
Collaborator

Sorry @nickevansuk , I've tweaked this now, let me know if it's resolved?

@nickevansuk
Copy link
Contributor Author

That's great, and the validator now works for this since your fix too!

http://validator.openactive.io/rpde?url=http://lr-api.staging.phoenixdigital.agency/public/v1/rides/

Note the issue in the validator relating to the last page - still one to fix there

@sevenpointsix
Copy link
Collaborator

Hi @nickevansuk . This is the final issue to fix I think! Our final page returns the message 'No ride data found' as a string, which is incorrect. How should we be rendering an empty page of data? Or, should we be excluding the "next" link on a page that has no valid "next" page?

@sevenpointsix sevenpointsix moved this from To do to In progress in British Cycling Endpoint Review Sep 6, 2018
@nickevansuk
Copy link
Contributor Author

If you check our the video in the earlier comment the last page stuff is explained near the end :)

Basically just has zero length array for items and the next page URL equal to the current page

@sevenpointsix sevenpointsix moved this from In progress to QA in British Cycling Endpoint Review Sep 7, 2018
@sevenpointsix
Copy link
Collaborator

Should be working now I think @nickevansuk ?

@nickevansuk
Copy link
Contributor Author

nickevansuk commented Sep 7, 2018

Just had a quick look... still errors... try running the validator and looking at the bottom of the list of errors?

http://validator.openactive.io/rpde?url=http://lr-api.staging.phoenixdigital.agency/public/v1/rides/

It looks like the last page still doesn't conform (e.g. http://api.letsride.co.uk/public/v1/rides?afterTimestamp=1536246355&afterId=27)

Also if you make the limit of items on items returned in each page 500 you'll get less warnings in the validator too.

@sevenpointsix
Copy link
Collaborator

I can't replicate this @nickevansuk , I only see warnings and no errors. Is it definitely throwing an error for you if you re-run a full validation?

@nickevansuk
Copy link
Contributor Author

Sorry I think you've found another bug in the validator, will investigate that...

Try this: http://validator.openactive.io/rpde?url=http%3A%2F%2Flr-api.staging.phoenixdigital.agency%2Fpublic%2Fv1%2Frides%3FafterTimestamp%3D2001%26afterId%3D8402

Also this page returns an error, but should look like a last page:
http://api.letsride.co.uk/public/v1/rides?afterTimestamp=1536246355&afterId=27

@sevenpointsix
Copy link
Collaborator

That second link is the live site @nickevansuk , we've fixed it on UAT (http://lr-api.staging.phoenixdigital.agency/public/v1/rides?afterTimestamp=1536246355&afterId=27). I've also fixed the issue found by the validator above.

@nickevansuk
Copy link
Contributor Author

Excellent! Were you able to adjust the page size to 500 too?

@sevenpointsix
Copy link
Collaborator

The feed should now be returning 500 items per page @nickevansuk

@nickevansuk
Copy link
Contributor Author

@nickevansuk
Copy link
Contributor Author

Seems to be resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants