Skip to content

Commit

Permalink
fix(lua): Fixed lua script to calculate total number of matching acco…
Browse files Browse the repository at this point in the history
…unts for a query
  • Loading branch information
andris9 committed Apr 25, 2024
1 parent 2838386 commit a4284c5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/lua/s-list-accounts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ local result = {}
-- sort list by account IDs
table.sort(list);

local listAll = false;
if strsearch and strsearch ~= '' then
listAll = true;
end

for index, account in ipairs(list) do

local state;
Expand All @@ -34,6 +39,7 @@ for index, account in ipairs(list) do

-- string search match defaults to true
local strmatch = true

if strsearch and strsearch ~= '' then
local account = redis.call("HGET", prefix .. "iad:" .. account, "account") or "";
local name = redis.call("HGET", prefix .. "iad:" .. account, "name") or "";
Expand All @@ -56,7 +62,7 @@ for index, account in ipairs(list) do
result[#result + 1] = redis.call("HGETALL", prefix .. "iad:" .. account);
else
-- max number entries in result buffer
if filterState == '*' then
if filterState == '*' and listAll == false then
-- no point looking further, we already know the total count
matching = total;
break;
Expand Down

0 comments on commit a4284c5

Please sign in to comment.