mod_storage_internal: Fix error in time limited queries on items without 'when' field, fixes #1557 0.11
authorKim Alvefur <zash@zash.se>
Fri, 15 May 2020 21:22:35 +0200
branch0.11
changeset 10847 8fcd46ee9bf5
parent 10838 c6e852984d48
child 10848 05f4386c846e
child 10916 646af16a3f32
mod_storage_internal: Fix error in time limited queries on items without 'when' field, fixes #1557
plugins/mod_storage_internal.lua
--- a/plugins/mod_storage_internal.lua	Mon May 11 21:14:02 2020 +0200
+++ b/plugins/mod_storage_internal.lua	Fri May 15 21:22:35 2020 +0200
@@ -104,12 +104,14 @@
 		end
 		if query.start then
 			items:filter(function (item)
-				return item.when >= query.start;
+				local when = item.when or datetime.parse(item.attr.stamp);
+				return when >= query.start;
 			end);
 		end
 		if query["end"] then
 			items:filter(function (item)
-				return item.when <= query["end"];
+				local when = item.when or datetime.parse(item.attr.stamp);
+				return when <= query["end"];
 			end);
 		end
 		count = #items;