Browse Source

Merge branch 'bug-fixes' into 'master'

fixed process counter and a other small bugs

See merge request medlabboulder/modpol!37
Nathan Schneider 1 year ago
parent
commit
23cf6abacd

+ 1 - 8
modpol_core/interactions/interactions.lua

@@ -169,14 +169,7 @@ function modpol.interactions.org_dashboard(user, org_string)
    table.sort(modules)
 
    -- list pending
-   local processes = {}
-   for i,v in ipairs(org.processes) do
-      if v ~= "deleted" then
-         processes[i] = org.processes[v]
-      end
-   end
-
-   local process_msg = #processes .. " total processes"
+   local process_msg = modpol.util.lazy_table_length(org.processes, "deleted") .. " total processes"
    if org.pending[user] then
       process_msg = process_msg .. " (" ..
          modpol.util.num_pairs(org.pending[user]) .. " pending)"

+ 1 - 0
modpol_core/orgs/base.lua

@@ -224,6 +224,7 @@ function modpol.orgs:delete()
     end
 
     modpol.orgs.array[self.id] = 'removed'
+    modpol.orgs.count = modpol.orgs.count - 1
     modpol.ocutil.log('Deleted org ' .. self.name .. ': ' .. self.id)
 
     self:record('Deleted ' .. self.name .. ' and all child orgs', 'del_org')

+ 1 - 1
modpol_core/storage/storage-local.lua

@@ -99,7 +99,7 @@ local load_orgs   = function()
         --     setmetatable(org, modpol.orgs)
         -- end
 
-        local nn  = modpol.ocutil.table_length (modpol.orgs.array)
+        local nn  = modpol.orgs.count
         local str = "entries"
         if nn == 1 then str = "entry" end
         modpol.ocutil.log (nn .. " orgs loaded from disk")

+ 10 - 0
modpol_core/util/misc.lua

@@ -32,3 +32,13 @@ function modpol.util.num_pairs(t)
    end
    return i
 end
+
+function modpol.util.lazy_table_length(tbl, lazy_val)
+   local count = 0
+   for k, v in ipairs(tbl) do
+      if v ~= lazy_val then
+         count = count + 1
+      end
+   end
+   return count
+end