fixed process count, added lazy table length function, removed orgs now decrement org counter, orgs loaded message should now be accurate
This commit is contained in:
		| @@ -169,7 +169,7 @@ function modpol.interactions.org_dashboard(user, org_string) | |||||||
|    table.sort(modules) |    table.sort(modules) | ||||||
|  |  | ||||||
|    -- list pending |    -- list pending | ||||||
|    local process_msg = #org.processes .. " total processes" |    local process_msg = modpol.util.lazy_table_length(org.processes, "deleted") .. " total processes" | ||||||
|    if org.pending[user] then |    if org.pending[user] then | ||||||
|       process_msg = process_msg .. " (" .. |       process_msg = process_msg .. " (" .. | ||||||
|          modpol.util.num_pairs(org.pending[user]) .. " pending)" |          modpol.util.num_pairs(org.pending[user]) .. " pending)" | ||||||
|   | |||||||
| @@ -224,6 +224,7 @@ function modpol.orgs:delete() | |||||||
|     end |     end | ||||||
|  |  | ||||||
|     modpol.orgs.array[self.id] = 'removed' |     modpol.orgs.array[self.id] = 'removed' | ||||||
|  |     modpol.orgs.count = modpol.orgs.count - 1 | ||||||
|     modpol.ocutil.log('Deleted org ' .. self.name .. ': ' .. self.id) |     modpol.ocutil.log('Deleted org ' .. self.name .. ': ' .. self.id) | ||||||
|  |  | ||||||
|     self:record('Deleted ' .. self.name .. ' and all child orgs', 'del_org') |     self:record('Deleted ' .. self.name .. ' and all child orgs', 'del_org') | ||||||
|   | |||||||
| @@ -99,7 +99,7 @@ local load_orgs   = function() | |||||||
|         --     setmetatable(org, modpol.orgs) |         --     setmetatable(org, modpol.orgs) | ||||||
|         -- end |         -- end | ||||||
|  |  | ||||||
|         local nn  = modpol.ocutil.table_length (modpol.orgs.array) |         local nn  = modpol.orgs.count | ||||||
|         local str = "entries" |         local str = "entries" | ||||||
|         if nn == 1 then str = "entry" end |         if nn == 1 then str = "entry" end | ||||||
|         modpol.ocutil.log (nn .. " orgs loaded from disk") |         modpol.ocutil.log (nn .. " orgs loaded from disk") | ||||||
|   | |||||||
| @@ -32,3 +32,13 @@ function modpol.util.num_pairs(t) | |||||||
|    end |    end | ||||||
|    return i |    return i | ||||||
| end | 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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user