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: stats.lua - slow_count option is unnecessary
Date Sun, 08 Jan 2017 11:54:27 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 2ebf5e7a7 -> 5b179d149


stats.lua - slow_count option is unnecessary

This fixes #323

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

Branch: refs/heads/master
Commit: 5b179d149d616797bd1258e81c9d89499a8f8c06
Parents: 2ebf5e7
Author: Sebb <sebb@apache.org>
Authored: Sun Jan 8 11:53:45 2017 +0000
Committer: Sebb <sebb@apache.org>
Committed: Sun Jan 8 11:53:45 2017 +0000

----------------------------------------------------------------------
 CHANGELOG.md       |   1 +
 site/api/stats.lua | 108 +++++-------------------------------------------
 tools/setup.py     |   1 -
 3 files changed, 12 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/5b179d14/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14e9c30..3e5ab70 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -110,6 +110,7 @@
 - cannot use absolute URLs in HTML pages (#328)
 - setup.py now prompts for shard and replica counts when creating the index (#313)
 - 'hot topics' feature should use terms, not significant_terms (#329)
+- stats.lua - slow_count option is unnecessary (#323)
 
 ## CHANGES in 0.9b:
 

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/5b179d14/site/api/stats.lua
----------------------------------------------------------------------
diff --git a/site/api/stats.lua b/site/api/stats.lua
index 62da9f1..e643bd6 100644
--- a/site/api/stats.lua
+++ b/site/api/stats.lua
@@ -339,67 +339,7 @@ function handle(r)
 
     local top10 = {}
 
-    if config.slow_count then
-        -- Debug time point 2
-        table.insert(t, r:clock() - tnow)
-        tnow = r:clock()
-        
-        local doc = elastic.raw {
-            size = 0, -- we don't need the hits themselves
-            aggs = {
-                from = {
-                    terms = {
-                        field = "from_raw",
-                        size = 10
-                    }
-                }
-            },
-            query = {
-                bool = {
-                    must = {
-                        {
-                            range = {
-                                date = daterange
-                            }
-                        },
-                        {
-                            query_string = {
-                                default_field = "subject",
-                                query = qs
-                            }
-                        },
-                        sterm
-                    },
-                    must_not = {
-                        {
-                            query_string = {
-                                default_field = "subject",
-                                query = nqs
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        
-    
-        -- Debug time point 3
-        table.insert(t, r:clock() - tnow)
-        tnow = r:clock()
-        
-        for x,y in pairs (doc.aggregations.from.buckets) do
-            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,
-                name = name,
-                count = y.doc_count
-            })
-        end
-    end
+    -- Debug time point 3 was for slow_count
     
     -- Debug time point 4
     table.insert(t, r:clock() - tnow)
@@ -595,7 +535,6 @@ 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
 
@@ -604,17 +543,15 @@ function handle(r)
             local gravatar = r:md5(eml:lower())
             email.gravatar = gravatar
 
-            if not config.slow_count then
-                local name = extractCanonName(email.from)
-                local eid = ("%s <%s>"):format(name, eml)
-                senders[eid] = senders[eid] or {
-                    email = eml,
-                    gravatar = gravatar,
-                    name = name,
-                    count = 0
-                }
-                senders[eid].count = senders[eid].count + 1
-            end
+            local name = extractCanonName(email.from)
+            local eid = ("%s <%s>"):format(name, eml)
+            senders[eid] = senders[eid] or {
+                email = eml,
+                gravatar = gravatar,
+                name = name,
+                count = 0
+            }
+            senders[eid].count = senders[eid].count + 1
             local mid = email['message-id']
             local irt = email['in-reply-to']
             email.id = v._id
@@ -696,20 +633,11 @@ function handle(r)
             else
                 table.insert(emls, {epoch= email.epoch})
             end
-        elseif config.slow_count then -- not authorised, fix up counts
-            for k, v in pairs(top10) do
-                -- 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
-            end
         end
     end
     
     local allparts = 0 -- number of participants
-    if not config.slow_count and not statsOnly then
+    if not statsOnly then
         local stable = {}
         for k, v in pairs(senders) do
             table.insert(stable, v)
@@ -725,19 +653,6 @@ function handle(r)
         end
     end
 
-    -- drop any non-participants and count the remainders
-    -- count the participants
-    if config.slow_count then
-        local top10_copy = top10
-        top10 = {}
-        for k, v in pairs(top10_copy) do
-            if v.count > 0 then
-                table.insert(top10, v)
-                allparts = allparts + 1
-            end
-        end
-    end
-
     -- anonymize emails if not logged in - anti-spam!
     if not account and config.antispam then
         for k, v in pairs(top10) do
@@ -787,7 +702,6 @@ function handle(r)
     tnow = r:clock()
     
     listdata.debug = t
-    listdata.slow_count = config.slow_count -- debug
     
     r:puts(JSON.encode(listdata))
     

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/5b179d14/tools/setup.py
----------------------------------------------------------------------
diff --git a/tools/setup.py b/tools/setup.py
index 19d4bd5..65957af 100755
--- a/tools/setup.py
+++ b/tools/setup.py
@@ -496,7 +496,6 @@ local config = {
 --  mailport = 1025, -- override the default port (25)
     accepted_domains = "%s",
     wordcloud = %s,
-    slow_count = false,
     email_footer = nil, -- see the docs for how to set this up.
     full_headers = false,
     maxResults = 5000, -- max emails to return in one go. Might need to be bumped for large
lists


Mime
View raw message