Browse files

Modify update range logic for agenda api

The agenda updates api takes a closed open datetime range as its
parameter.  This is problematic in practice because the typical use case
involves passing the last received update datetime as the "from"
parameter.  This means that you will receive that same update again
because its update time is >= the datetime in the "from" parameter.  The
other updates apis use an open range.

This commit changes the date range parsing logic to query for an open
range based on the input "from" and "to" datetimes.  Also, the
@RequestMapping annotations have been modified to prevent sub-second
precision times from being lopped off due spring thinking they are file
  • Loading branch information...
McSquirrel committed Jan 9, 2018
1 parent ff805ff commit cc5ff67110f860c18775ada06b28a61bc884d3f8
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/main/java/gov/nysenate/openleg/controller/api/agenda/
@@ -68,7 +68,7 @@ public BaseResponse getRecentUpdates(WebRequest request) {
return getUpdatesDuring(,, request);
@RequestMapping(value = "/updates/{from}")
@RequestMapping(value = "/updates/{from:.*\\.?.*}")
public BaseResponse getUpdatesFrom(@PathVariable String from, WebRequest request) {
return getUpdatesDuring(parseISODateTime(from, "from"),, request);
@@ -102,7 +102,7 @@ public BaseResponse getUpdatesForBill(@PathVariable int year, @PathVariable int, request);
@RequestMapping(value = "/{year:[\\d]{4}}/{agendaNo}/updates/{from}")
@RequestMapping(value = "/{year:[\\d]{4}}/{agendaNo}/updates/{from:.*\\.?.*}")
public BaseResponse getUpdatesForBill(@PathVariable int year, @PathVariable int agendaNo, @PathVariable String from,
WebRequest request) {
LocalDateTime fromDateTime = parseISODateTime(from, "from");
@@ -122,7 +122,7 @@ public BaseResponse getUpdatesForBillDuring(@PathVariable int year, @PathVariabl
private BaseResponse getUpdatesDuring(LocalDateTime from, LocalDateTime to, WebRequest request) {
// Fetch params
LimitOffset limOff = getLimitOffset(request, 50);
Range<LocalDateTime> updateRange = getClosedOpenRange(from, to, "from", "to");
Range<LocalDateTime> updateRange = getOpenRange(from, to, "from", "to");
boolean detail = getBooleanParam(request, "detail", false);
SortOrder sortOrder = getSortOrder(request, SortOrder.ASC);
UpdateType updateType = getUpdateTypeFromParam(request);

0 comments on commit cc5ff67

Please sign in to comment.