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: ll.py - show private message counts
Date Sat, 14 Jan 2017 13:57:19 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 187660a27 -> 2398a770f


ll.py - show private message counts


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

Branch: refs/heads/master
Commit: 2398a770fa3a2dcf0f57fcaf4261432a994f22da
Parents: 187660a
Author: Sebb <sebb@apache.org>
Authored: Sat Jan 14 12:33:27 2017 +0000
Committer: Sebb <sebb@apache.org>
Committed: Sat Jan 14 12:55:01 2017 +0000

----------------------------------------------------------------------
 CHANGELOG.md |  2 +-
 tools/ll.py  | 32 +++++++++++++++++++++++---------
 2 files changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/2398a770/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6203c01..23465cf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -119,7 +119,7 @@
 - Always use Javascript conditional blocks (#333)
 - links in stats pane don't set up the correct date range (#106)
 - code should delete scroll id after use (#336)
-- ll.py - Make --count work with --pretty
+- ll.py - Make --count work with --pretty; show private message counts
 - DRY: move leapYear and end of month calculations to utils
 
 ## CHANGES in 0.9b:

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/2398a770/tools/ll.py
----------------------------------------------------------------------
diff --git a/tools/ll.py b/tools/ll.py
index 1064c7c..47df5f1 100755
--- a/tools/ll.py
+++ b/tools/ll.py
@@ -68,6 +68,15 @@ page = es.search(
                 'terms': {
                     'field': "list_raw",
                     'size': 500000
+                },
+                'aggs': {
+                    'privacy' : {
+                        'filter' : {# are there any private messages?
+                            'term': {
+                                 'private': True
+                            }
+                        }
+                    }
                 }
             }
         },
@@ -98,26 +107,31 @@ parser.add_argument('--counts', dest='counts', action='store_true',
 args = parser.parse_args()
 pretty = args.pretty
 plist = {}
-
+total_private = 0
 if args.debug:
-    print(json.dumps(page['aggregations']))
+    print(json.dumps(page))
 else:
     for domain in page['aggregations']['lists']['buckets']:
+        listid = domain['key']
+        msgcount = domain['doc_count']
+        prvcount = domain['privacy']['doc_count']
+        total_private += prvcount
         if pretty:
-            if domain['key'].find(".") != -1:
-                l, d = domain['key'].strip("<>").split(".", 1)
+            if listid.find(".") != -1:
+                l, d = listid.strip("<>").split(".", 1)
                 plist[d] = plist[d] if d in plist else {}
-                plist[d][l]=domain['doc_count']
+                plist[d][l]=[msgcount, prvcount]
         else:
             if args.counts:
-                print(domain['key'],domain['doc_count'])
+                print(listid, msgcount, prvcount)
             else:
-                print(domain['key'])
+                print(listid)
     
     for dom in sorted(plist):
         for ln in sorted(plist[dom]):
             if args.counts:
-                print("%s@%s %d" % (ln, dom, plist[dom][ln]))
+                print("%s@%s %d %d" % (ln, dom, plist[dom][ln][0], plist[dom][ln][1]))
             else:
                 print("%s@%s" % (ln, dom))
-            
\ No newline at end of file
+    if args.counts:
+        print("Total messages %d of which private %d" % (page['hits']['total'], total_private))


Mime
View raw message