Unsolved Bookend point-values for time range
-
Is there a way when retrieving a time range of point-values via the Mango API to include the last logged value prior to the beginning of the time range, and the first logged value after the time range?
This is primarily for graphing purposes, so that data-points with infrequent value changes will have accurate data at the beginning and end of the graph, or even if the selected time range contains no logged values.
-
Hi dstoryQuest, welcome to the forum!
Have you checked the bookend option on the existing /rest/v2/point-values endpoints? Most include a "bookend" boolean request parameter that will add one, possibly two data values to the data returned which are,
- Bookend start value - the value the point had at the start millisecond of the period. If there was a sample exactly at that time it is a real value, otherwise it is marked as a bookend and presented as having the same timestamp as the requested period start time.
- Bookend end value - the last value in the period or the start value, presented with the period end timestamp. Because all Mango time queries have an inclusive start time but an exclusive end time, the value presented as the closing bookend is always flagged as a bookend value (as opposed to being a real value at that time, since even if there were one it would be excluded by the end time being exclusive)
So that's slightly different than what you're requesting since the timestamps match the times for the period requested, but I suspect that is nicer behavior for a user requesting a specific time period. There is not a way through the API to query for one additional value on either side of a period, but there is support for that in the NoSQL database (which is what we're using, just possibly fibbing on the timestamps), so it would be easy to add. We chose what we did to not affect the time period covered in the result.