ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject incubator-ponymail git commit: Ensure comparison works even if there are future dated entries
Date Tue, 24 Jan 2017 11:37:20 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master c3bfd04bd -> d8fea0a6f


Ensure comparison works even if there are future dated entries

Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/d8fea0a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/d8fea0a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/d8fea0a6

Branch: refs/heads/master
Commit: d8fea0a6f5a9cf9eeaf546deac8bd701078aaf3e
Parents: c3bfd04
Author: Sebb <sebb@apache.org>
Authored: Tue Jan 24 11:37:06 2017 +0000
Committer: Sebb <sebb@apache.org>
Committed: Tue Jan 24 11:37:06 2017 +0000

----------------------------------------------------------------------
 site/api/stats.lua | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/d8fea0a6/site/api/stats.lua
----------------------------------------------------------------------
diff --git a/site/api/stats.lua b/site/api/stats.lua
index 647d289..27b52c8 100644
--- a/site/api/stats.lua
+++ b/site/api/stats.lua
@@ -429,19 +429,22 @@ function handle(r)
             }
         }
         datespan = {}
-        local NOW = os.time()
-        datespan.pubfirst = NOW -- earliest time must be less than this
-        datespan.publast = 0
+        datespan.pubfirst = nil
+        datespan.publast = nil
         -- find public min and max (buckets will be empty if there are no matching lists)
         for _, list in pairs(doc.aggregations.lists.buckets) do
             for _, private in pairs(list.private.buckets) do
                 if private.key_as_string == "false" then
-                    if private.last.value > datespan.publast then datespan.publast = private.last.value
end
-                    if private.first.value < datespan.pubfirst then datespan.pubfirst
= private.first.value end
+                    if (datespan.publast == nil) or (private.last.value > datespan.publast)
then datespan.publast = private.last.value end
+                    if (datespan.pubfirst == nil) or (private.first.value < datespan.pubfirst)
then datespan.pubfirst = private.first.value end
                 end
             end
         end
-        if datespan.publast == 0 then datespan.publast = NOW end -- no value found
+        if datespan.publast == nil then -- did not find any values
+            local NOW = os.time()
+            datespan.publast = NOW 
+            datespan.pubfirst = NOW 
+        end
 
         -- find private min and max and store them if they could change the public ones
         -- store the list entries under the 'private' key to make them easier to process


Mime
View raw message