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: Properly fix #301
Date Wed, 04 Jan 2017 18:25:02 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 33393fa82 -> 570987088


Properly fix #301

Ensure we allow for duplicates after canonicalisation

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

Branch: refs/heads/master
Commit: 570987088d18b29bb8bd8baee58039ce33f18d7d
Parents: 33393fa
Author: Sebb <sebb@apache.org>
Authored: Wed Jan 4 18:24:51 2017 +0000
Committer: Sebb <sebb@apache.org>
Committed: Wed Jan 4 18:24:51 2017 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/57098708/site/api/stats.lua
----------------------------------------------------------------------
diff --git a/site/api/stats.lua b/site/api/stats.lua
index 8b7a273..43669a4 100644
--- a/site/api/stats.lua
+++ b/site/api/stats.lua
@@ -391,6 +391,7 @@ function handle(r)
             local eml = utils.extractCanonEmail(y.key)
             local gravatar = r:md5(eml:lower())
             local name = extractCanonName(y.key)
+            -- N.B. the canonicalisation process can result in duplicates in the top10 table
             table.insert(top10, {
                 email = eml,
                 gravatar = gravatar,
@@ -600,12 +601,12 @@ function handle(r)
         if eepoch > lastEmail then
             lastEmail = eepoch
         end
+        -- This is also needed by ths slow_count method            
+        local eml = utils.extractCanonEmail(email.from)
         if aaa.canAccessDoc(r, email, account) then
 
             h = h + 1
 
-            -- This is needed by ths slow_count method            
-            local eml = utils.extractCanonEmail(email.from)
             local gravatar = r:md5(eml:lower())
             email.gravatar = gravatar
 
@@ -704,9 +705,11 @@ function handle(r)
             else
                 table.insert(emls, {epoch= email.epoch})
             end
-        elseif config.slow_count then
+        elseif config.slow_count then -- not authorised, fix up counts
             for k, v in pairs(top10) do
-                if v.email == utils.extractCanonEmail(email.from) then
+                -- because of canonicalisation, there can be multiple matches in the top10
list
+                -- carry on to next match if first one is exhausted
+                if v.email == eml and v.count > 0 then
                     v.count = v.count - 1
                     break -- don't count the e-mail again
                 end


Mime
View raw message