Skip to content

Commit de0a346

Browse files
committed
Remove redundant full-scan on stat build
Need for #92
1 parent 832691a commit de0a346

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

queue/abstract.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,13 +540,16 @@ local function build_stats(space)
540540
end
541541
end
542542

543-
-- add total tasks count
544-
stats['tasks']['total'] = box.space[space].index[idx_tube]:count()
545-
543+
local total = 0
546544
-- add tasks by state count
547545
for i, s in pairs(state) do
548-
stats['tasks'][i:lower()] = box.space[space].index[idx_tube]:count(s)
546+
local st = i:lower()
547+
stats['tasks'][st] = box.space[space].index[idx_tube]:count(s)
548+
total = total + stats['tasks'][st]
549549
end
550+
551+
-- add total tasks count
552+
stats['tasks']['total'] = total
550553
stats['tasks']['done'] = st.done or 0
551554

552555
return stats

0 commit comments

Comments
 (0)