mod_storage_internal: Fix off-by-one when searching archive for
Fixes a test case provided by MattJ where the very first item matched by
a 'start' timestamp was not returned.
--- a/plugins/mod_storage_internal.lua Thu Jan 11 07:54:11 2024 +0100
+++ b/plugins/mod_storage_internal.lua Thu Feb 15 20:28:14 2024 +0100
@@ -200,15 +200,11 @@
end
if query.start then
if not query.reverse then
- local wi, exact = binary_search(list, function(item)
+ local wi = binary_search(list, function(item)
local when = item.when or datetime.parse(item.attr.stamp);
return query.start - when;
end);
- if exact then
- i = wi - 1;
- elseif wi then
- i = wi;
- end
+ i = wi - 1;
else
iter = it.filter(function(item)
local when = item.when or datetime.parse(item.attr.stamp);