Diff

plugins/mod_mam/mod_mam.lua @ 9757:03ed7f10d8da

mod_mam: Measure how long it takes to run the message expiry job job
author Kim Alvefur <zash@zash.se>
date Sun, 06 Jan 2019 09:34:59 +0100
parent 9752:5cc2765c3ce4
child 9758:d4a534e6bd7c
line wrap: on
line diff
--- a/plugins/mod_mam/mod_mam.lua	Fri Jan 04 15:13:52 2019 +0100
+++ b/plugins/mod_mam/mod_mam.lua	Sun Jan 06 09:34:59 2019 +0100
@@ -351,8 +351,10 @@
 	function schedule_cleanup(username, date)
 		cleanup_map:set(date or datestamp(), username, true);
 	end
+	local cleanup_time = module:measure("cleanup", "times");
 
 	cleanup_runner = require "util.async".runner(function ()
+		local cleanup_done = cleanup_time();
 		local users = {};
 		local cut_off = datestamp(os.time() - cleanup_after);
 		for date in cleanup_storage:users() do
@@ -376,6 +378,7 @@
 			end
 		end
 		module:log("info", "Deleted %d expired messages for %d users", sum, num_users);
+		cleanup_done();
 	end);
 
 	cleanup_task = module:add_timer(1, function ()