refactor: replace cleanup service with focused temp role service and fix daily streaks

This commit is contained in:
syntaxbullet
2026-01-07 11:04:34 +01:00
parent 4a1e72c5f3
commit ca392749e3
9 changed files with 206 additions and 341 deletions

View File

@@ -1,32 +1,21 @@
import { cleanupService } from "./cleanup.service";
import { config } from "@/lib/config";
import { temporaryRoleService } from "./temp-role.service";
/**
* The Scheduler responsible for periodic tasks and system maintenance.
*/
export const schedulerService = {
start: () => {
console.log("🕒 Scheduler started: Maintenance loops initialized.");
// 1. High-frequency timer cleanup (every 60s)
// This handles role revocations and cooldown expirations
// 1. Temporary Role Revocation (every 60s)
setInterval(() => {
cleanupService.cleanupTimers();
temporaryRoleService.processExpiredRoles();
}, 60 * 1000);
// 2. Scheduled system cleanup (configurable, default daily)
// This handles lootdrops, quests, etc.
setInterval(() => {
cleanupService.runAll();
}, config.system.cleanup.intervalMs);
// 3. Terminal Update Loop (every 60s)
// 2. Terminal Update Loop (every 60s)
const { terminalService } = require("@/modules/terminal/terminal.service");
setInterval(() => {
terminalService.update();
}, 60 * 1000);
// Run an initial cleanup on start for good measure
cleanupService.runAll();
// Run an initial check on start
temporaryRoleService.processExpiredRoles();
}
};