You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2017/01/07 01:49:58 UTC

[1/2] incubator-ponymail git commit: Localise variables as far as possible

Repository: incubator-ponymail
Updated Branches:
  refs/heads/master f843e6891 -> 4d165cab2


Localise variables as far as possible

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

Branch: refs/heads/master
Commit: a0b00093f47df41e089c3438ecb25c0fc62cf670
Parents: f843e68
Author: Sebb <se...@apache.org>
Authored: Fri Jan 6 22:23:56 2017 +0000
Committer: Sebb <se...@apache.org>
Committed: Fri Jan 6 22:23:56 2017 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/a0b00093/site/api/stats.lua
----------------------------------------------------------------------
diff --git a/site/api/stats.lua b/site/api/stats.lua
index 423af53..cd61cf7 100644
--- a/site/api/stats.lua
+++ b/site/api/stats.lua
@@ -102,19 +102,14 @@ function handle(r)
     if get.d and tonumber(get.d) and tonumber(get.d) > 0 then
         dd = tonumber(get.d)
     end
-    local x
-    local nx
-    local y
-    local z
-    local ec
     -- Param: q=query
     if get.q and #get.q > 0 then
-        x = {}
-        nx = {}
+        local x = {}
+        local nx = {}
         local q = get.q:gsub("+", " ") -- apache quirk?
         for k, v in pairs({'from','subject','body'}) do
-            y = {}
-            z = {}
+            local y = {}
+            local z = {}
             local words = {}
             
             -- first, grab all "foo bar" quotes
@@ -163,7 +158,7 @@ function handle(r)
         domain = get.domain
     }
 
-    z = {}
+    local z = {}
     -- Param: header_from=
     -- Param: header_subject=
     -- Param: header_body=
@@ -256,7 +251,7 @@ function handle(r)
     if get.s and get.e then
         local em = tonumber(get.e:match("%-(%d%d?)$"))
         local ey = tonumber(get.e:match("^(%d%d%d%d)"))
-        ec = days[em]
+        local ec = days[em]
         if em == 2 and leapYear(ey) then
             ec = ec + 1
         end


[2/2] incubator-ponymail git commit: More variable localisation

Posted by se...@apache.org.
More variable localisation

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

Branch: refs/heads/master
Commit: 4d165cab2f39aceb4395b67360096fdc74ccafdb
Parents: a0b0009
Author: Sebb <se...@apache.org>
Authored: Sat Jan 7 01:49:46 2017 +0000
Committer: Sebb <se...@apache.org>
Committed: Sat Jan 7 01:49:46 2017 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/4d165cab/site/api/stats.lua
----------------------------------------------------------------------
diff --git a/site/api/stats.lua b/site/api/stats.lua
index cd61cf7..a8f11ec 100644
--- a/site/api/stats.lua
+++ b/site/api/stats.lua
@@ -282,9 +282,9 @@ function handle(r)
             }
         }
     end
-    
-    local top10 = {}
-    local allparts = 0 -- number of participants
+
+--[[ ============ Completed all parameter parsing, now process the data ============ ]]
+
     -- Check for changes?
     -- Param: since=epoch (optional, defaults to now)
     if get.since then
@@ -326,8 +326,7 @@ function handle(r)
             },
             size = 1
         }
-        local h = #doc.hits.hits
-        if h == 0 then
+        if #doc.hits.hits == 0 then
             r:puts(JSON.encode{
                 changed = false,
                 took = r:clock() - tnow
@@ -335,7 +334,9 @@ function handle(r)
             return cross.OK
         end
     end
-    
+
+    local top10 = {}
+
     if config.slow_count then
         -- Debug time point 2
         table.insert(t, r:clock() - tnow)
@@ -705,6 +706,7 @@ function handle(r)
         end
     end
     
+    local allparts = 0 -- number of participants
     if not config.slow_count and not statsOnly then
         local stable = {}
         for k, v in pairs(senders) do