Comparison

core/moduleapi.lua @ 12002:cbed7d8d8f35

mod_cron: Add a 'weekly' job frequency
author Kim Alvefur <zash@zash.se>
date Fri, 03 Dec 2021 09:05:41 +0100
parent 11987:4b519c575ad0
child 12095:c1d2bc6603ae
comparison
equal deleted inserted replaced
12001:5a8c6f9a4583 12002:cbed7d8d8f35
519 function api:daily(name, fun) 519 function api:daily(name, fun)
520 if type(name) == "function" then fun, name = name, nil; end 520 if type(name) == "function" then fun, name = name, nil; end
521 self:cron({ name = name; when = "daily"; run = fun }); 521 self:cron({ name = name; when = "daily"; run = fun });
522 end 522 end
523 523
524 function api:weekly(name, fun)
525 if type(name) == "function" then fun, name = name, nil; end
526 self:cron({ name = name; when = "weekly"; run = fun });
527 end
528
524 local path_sep = package.config:sub(1,1); 529 local path_sep = package.config:sub(1,1);
525 function api:get_directory() 530 function api:get_directory()
526 return self.resource_path or self.path and (self.path:gsub("%"..path_sep.."[^"..path_sep.."]*$", "")) or nil; 531 return self.resource_path or self.path and (self.path:gsub("%"..path_sep.."[^"..path_sep.."]*$", "")) or nil;
527 end 532 end
528 533