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 2016/12/17 13:10:12 UTC

[1/3] incubator-ponymail git commit: preferences.lua never fetches descriptions

Repository: incubator-ponymail
Updated Branches:
  refs/heads/master ab64bc43d -> 0e5d323dd


preferences.lua never fetches descriptions

This fixes #163

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

Branch: refs/heads/master
Commit: b7e8dd99cfa273b159e931c205238915f9fded58
Parents: ab64bc4
Author: Sebb <se...@apache.org>
Authored: Sat Dec 17 10:23:22 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Sat Dec 17 10:23:22 2016 +0000

----------------------------------------------------------------------
 CHANGELOG.md             | 1 +
 site/api/preferences.lua | 8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/b7e8dd99/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c1816d8..3a30d7d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -77,6 +77,7 @@
 - elastic.lua:getHeaders uses different sort field (#146)
 - redundant matching of same string (#117)
 - ponymail.js uses unsupported preferences.lua parameter (#165)
+- preferences.lua never fetches descriptions (#163)
 
 ## CHANGES in 0.9b:
 

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/b7e8dd99/site/api/preferences.lua
----------------------------------------------------------------------
diff --git a/site/api/preferences.lua b/site/api/preferences.lua
index 7d97640..f585833 100644
--- a/site/api/preferences.lua
+++ b/site/api/preferences.lua
@@ -345,13 +345,13 @@ Pony Mail - Email for Ponies and People.
     end
      
     account = account or {}
-    local _, descs = pcall(function() return elastic.find("*", 9999, "mailinglists", "name") end) or nil
-    if not descs then
-        descs = {}
+    local stat, descs = pcall(function() return elastic.find("*", 9999, "mailinglists", "name") end)
+    if not stat or not descs then
+        descs = {} -- ensure descs is valid
     end
     -- try to extrapolate foo@bar.tld here
     for k, v in pairs(descs) do
-        local l, d = v.list:lower():match("<([^.]+)%.(.-)>")
+        local _, l, d = aaa.parseLid(v.list:lower())
         if l and d then
             descs[k].lid = ("%s@%s"):format(l, d)
         else


[3/3] incubator-ponymail git commit: API.md does not document all the stats.lua parameters

Posted by se...@apache.org.
API.md does not document all the stats.lua parameters

This fixes #115

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

Branch: refs/heads/master
Commit: 0e5d323dda43f6e125ac80ec9b936fb865bb7344
Parents: dfe2066
Author: Sebb <se...@apache.org>
Authored: Sat Dec 17 13:09:58 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Sat Dec 17 13:09:58 2016 +0000

----------------------------------------------------------------------
 CHANGELOG.md |  2 ++
 docs/API.md  | 20 +++++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/0e5d323d/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3a30d7d..7ff6249 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -78,6 +78,8 @@
 - redundant matching of same string (#117)
 - ponymail.js uses unsupported preferences.lua parameter (#165)
 - preferences.lua never fetches descriptions (#163)
+- API.md does not document all the stats.lua parameters (#115)
+
 
 ## CHANGES in 0.9b:
 

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/0e5d323d/docs/API.md
----------------------------------------------------------------------
diff --git a/docs/API.md b/docs/API.md
index 4713578..2fb64a2 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -38,18 +38,23 @@ Response example:
 
 ### Fetching list data
 Usage:
-`GET /api/stats.lua?list=$list&domain=$domain[&d=$timespan][&q=$query][&header_from=$from][&header_subject=$subject]`
+`GET /api/stats.lua?list=$list&domain=$domain[&d=$timespan][&q=$query][&header_from=$from][&header_to=$to][&header_subject=$subject][&header_body=$body][&quick][&s=$s&e=$e]`
 
 Parameters:
+
     - $list: The list prefix (e.g. `dev`). Wildcards may be used
     - $domain: The list domain (e.g. `httpd.apache.org`). Wildcards may be used
     - $timespan: A [timespan](#Timespans) value
+    - $s: yyyy-mm start of month (day 1)
+    - $e: yyyy-mm end of month (last day)
     - $query: A search query (may contain wildcards or negations):
       - `foo`: Find all documents containing `foo` in headers or body
       - `-foo`: Find all documents NOT containing `foo`.
       - `foo*`: Find all documents containing `foo`, `fooa`, `foob` etc
     - $from: Optional From: address
+    - $to: Optional To: address
     - $subject: Optional Subject: line
+    - $body: Optional body text
     
 Response example:
 
@@ -94,6 +99,19 @@ Response example:
 }
 ~~~
 
+### <a name="Timespans"></a>Timespans
+
+Timespans supported by the &d= parameter.
+
+    - d=nnnn
+    - d=yyyy-mm => equivalent to &s=yyyy-mm&e=yyyy-mm
+    - d=lte=n[wMyd] (less than n[wMyd] ago, inclusive)
+    - d=gte=n[wMyd] (more than n[wMyd] ago, inclusive)
+    - d=.*dfr=yyyy-mm-dd.* (start date for search, inclusive)
+    - d=.*dto=yyyy-mm-dd.* (end date for search, inclusive)
+    - [wMyd] = weeks, Months, years, days
+    - lte and gte are mutually exclusive
+    - dfr and dto are normally both present
 
 ### Fetching preferences and quick list overview
 Usage:


[2/3] incubator-ponymail git commit: Docs for params

Posted by se...@apache.org.
Docs for params

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

Branch: refs/heads/master
Commit: dfe20661cae4f71a641a1c1f8c80cea0a589750b
Parents: b7e8dd9
Author: Sebb <se...@apache.org>
Authored: Sat Dec 17 13:09:02 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Sat Dec 17 13:09:02 2016 +0000

----------------------------------------------------------------------
 site/api/stats.lua | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/dfe20661/site/api/stats.lua
----------------------------------------------------------------------
diff --git a/site/api/stats.lua b/site/api/stats.lua
index 185bb8d..14d3ee2 100644
--- a/site/api/stats.lua
+++ b/site/api/stats.lua
@@ -92,17 +92,22 @@ function handle(r)
     local lastEmail = 0
     -- statsOnly: Whether to only send statistical info (for n-grams etc), and not the
     -- thread struct and message bodies
+    -- Param: quick
     local statsOnly = get.quick
+    -- Param: list=<listname> or '*' (required)
+    -- Param: domain=<domain> or '*' (required)
     if not get.list or not get.domain then
         r:puts("{}")
         return cross.OK
     end
-    local qs = "*"
-    local nqs = ""
+    local qs = "*" -- positive query
+    local nqs = "" -- negative query
     local dd = "lte=1M"
     local maxresults = config.maxResults or 5000
     local account = user.get(r)
     local rights = nil
+    -- Param: d=nnnnn (numeric)
+    -- does not appear to be supported below
     if get.d and tonumber(get.d) and tonumber(get.d) > 0 then
         dd = tonumber(get.d)
     end
@@ -111,6 +116,7 @@ function handle(r)
     local y
     local z
     local ec
+    -- Param: q=query
     if get.q and #get.q > 0 then
         x = {}
         nx = {}
@@ -167,6 +173,10 @@ function handle(r)
     }
 
     z = {}
+    -- Param: header_from=
+    -- Param: header_subject=
+    -- Param: header_body=
+    -- Param: header_to=
     for k, v in pairs({'from','subject','body', 'to'}) do
         if get['header_' .. v] then
             local word = get['header_' .. v]
@@ -186,6 +196,9 @@ function handle(r)
     tnow = r:clock()
     
     local daterange = {gt = "now-1M", lte = "now+1d" }
+    -- Param: dfrom=.*ddd (days ago to start)
+    -- Param: dto=dddd.* (total days to match)
+    -- Must both be present
     if get.dfrom and get.dto then
         local ef = tonumber(get.dfrom:match("(%d+)$")) or 0
         local et = tonumber(get.dto:match("^(%d+)")) or 0
@@ -204,10 +217,13 @@ function handle(r)
     end
     
     -- d=YYYY-mm translates into s+e being equal to d
+    -- Param: d=yyyy-mm
     if not (get.s and get.e) and get.d and get.d:match("^%d+%-%d+$") then
         get.s = get.d
         get.e = get.d
     end
+    -- Param: d=.*lte=n[wMyd].* (how long ago to start search)
+    -- from now-nP to now+1d (P=period)
     if get.d then
         local lte = get.d:match("lte=([0-9]+[wMyd])")
         if lte then
@@ -216,6 +232,8 @@ function handle(r)
             daterange.gt = nil
         end
     end
+    -- Param: d=.*gte=n[wMyd].* (how long ago to end search)
+    -- before now-nP (P=period)
     if get.d then
         local gte = get.d:match("gte=([0-9]+[wMyd])")
         if gte then
@@ -224,6 +242,8 @@ function handle(r)
             daterange.lte = "now-" .. gte
         end
     end
+    -- Param: d=.*dfr=yyyy-mm-dd.*
+    -- start date for search
     if get.d then
         local y,m,d = get.d:match("dfr=(%d+)%-(%d+)%-(%d+)")
         if y and m and d then
@@ -231,6 +251,8 @@ function handle(r)
             daterange.gt = nil
         end
     end
+    -- Param: d=.*dto=yyyy-mm-dd.*
+    -- end date for search
     if get.d then
         local y,m,d = get.d:match("dto=(%d+)%-(%d+)%-(%d+)")
         if y and m and d then
@@ -238,6 +260,8 @@ function handle(r)
             daterange.gt = nil
         end
     end
+    -- Param: s=yyyy-m[m]
+    -- Param: e=yyyy-m[m]
     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)"))
@@ -275,8 +299,10 @@ function handle(r)
     
     local top10 = {}
     local allparts = 0
-    
+    r:warn(get.d)
+    r:warn(JSON.encode(daterange))
     -- Check for changes?
+    -- Param: since=epoch (optional, defaults to now)
     if get.since then
         local epoch = tonumber(get.since) or os.time()
         local doc = elastic.raw {