openactive / realtime-paged-data-exchange

OpenActive Realtime Paged Data Exchange Specification
https://www.openactive.io/realtime-paged-data-exchange/
Other
6 stars 1 forks source link

Single item on a page: FirstTimeAfterTimestampAndAfterIdException #101

Closed jeremyswright closed 4 years ago

jeremyswright commented 4 years ago

When a feed produces a page with a single item on it, how do I get round this check in RpdeBody->createFromModifiedId?

Thanks.


            $firstItem = $items[0];

            // Checks that the afterId and afterTimestamp provided are not the
            // first item in the feed (helps detect whether query is correct)
            if (
                $firstItem->getModified() === $modified &&
                $firstItem->getId() === $id
            ) {
                throw new FirstTimeAfterTimestampAndAfterIdException();
            }
nickevansuk commented 4 years ago

@jeremyswright this check is a confirmation of the RPDE query:

https://www.w3.org/2017/08/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

You may have seen this mentioned in the RPDE validator or elsewhere in the documentation:

Misreading the query in the specification is the single most common cause of incorrect implementation. Please read it carefully and ensure that brackets and comparators are used correctly. > not >= for example.

So the above check should always pass, even for a single item. Hope this helps!