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/04 13:16:27 UTC

incubator-ponymail git commit: elastic.scroll does not return nil sid when there are no more results

Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 77bb141a9 -> ba7b1753d


elastic.scroll does not return nil sid when there are no more results

This fixes #315

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

Branch: refs/heads/master
Commit: ba7b1753d0a0c5fd6866fce465d9b776a39b2e29
Parents: 77bb141
Author: Sebb <se...@apache.org>
Authored: Wed Jan 4 13:13:27 2017 +0000
Committer: Sebb <se...@apache.org>
Committed: Wed Jan 4 13:13:27 2017 +0000

----------------------------------------------------------------------
 CHANGELOG.md        |  1 +
 site/api/pminfo.lua | 12 +++---------
 site/api/stats.lua  |  3 ---
 3 files changed, 4 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ba7b1753/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 607214b..73f5158 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -95,6 +95,7 @@
 - Updated Google+ API for logins
 - Fixed a redirect bug with oauth
 - Removed support for Mozilla Persona
+- elastic.scroll does not return nil sid when there are no more results (#315)
 
 ## CHANGES in 0.9b:
 

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ba7b1753/site/api/pminfo.lua
----------------------------------------------------------------------
diff --git a/site/api/pminfo.lua b/site/api/pminfo.lua
index bb99b04..8011510 100644
--- a/site/api/pminfo.lua
+++ b/site/api/pminfo.lua
@@ -179,21 +179,15 @@ function handle(r)
         size = MAXRESULTS
     }
     local h = 0
-    local maxScrolls = 5
     local hits = {}
-    while sid ~= nil do
-        maxScrolls = maxScrolls - 1
-        if maxScrolls < 0 then
-            break
-        end
+    if sid then
         doc, sid = elastic.scroll(sid)
-        if doc then
+        while doc and doc.hits and doc.hits.hits and #doc.hits.hits > 0 do -- scroll as long as we get new results
             h = h + #doc.hits.hits
             for k, v in pairs(doc.hits.hits) do
                 table.insert(hits, v)
             end
-        else
-            break
+            doc, sid = elastic.scroll(sid)
         end
     end
     

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ba7b1753/site/api/stats.lua
----------------------------------------------------------------------
diff --git a/site/api/stats.lua b/site/api/stats.lua
index 6740b76..14950cf 100644
--- a/site/api/stats.lua
+++ b/site/api/stats.lua
@@ -573,9 +573,6 @@ function handle(r)
                 for k, v in pairs(js.hits.hits) do
                     table.insert(dhh, v)
                 end
-                if not sid then -- break if last scroll
-                    break
-                end
                 js, sid = elastic.scroll(sid)
             end
         end