|
|
|
|
@ -75,8 +75,9 @@ export class GroupSyncService {
|
|
|
|
|
private static _groupsIntervalMs: number | null = null;
|
|
|
|
|
private static _groupsNextTickAt: number | null = null;
|
|
|
|
|
private static _membersGlobalCooldownUntil: number = 0;
|
|
|
|
|
private static _lastChangedActive: string[] = [];
|
|
|
|
|
|
|
|
|
|
static async syncGroups(force: boolean = false): Promise<{ added: number; updated: number; changedActive: string[] }> {
|
|
|
|
|
static async syncGroups(force: boolean = false): Promise<{ added: number; updated: number }> {
|
|
|
|
|
if (!this.shouldSync(force)) {
|
|
|
|
|
return { added: 0, updated: 0 };
|
|
|
|
|
}
|
|
|
|
|
@ -189,7 +190,9 @@ export class GroupSyncService {
|
|
|
|
|
// Duración opcional
|
|
|
|
|
Metrics.set('last_sync_duration_ms', Date.now() - (typeof startedAt !== 'undefined' ? startedAt : Date.now()));
|
|
|
|
|
|
|
|
|
|
return { ...result, changedActive: newlyActivatedIds };
|
|
|
|
|
// Guardar lista de grupos que han pasado a activos para consumo externo
|
|
|
|
|
this._lastChangedActive = Array.isArray(newlyActivatedIds) ? newlyActivatedIds : [];
|
|
|
|
|
return result;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Group sync failed:', error);
|
|
|
|
|
Metrics.inc('sync_errors_total');
|
|
|
|
|
@ -1010,6 +1013,14 @@ export class GroupSyncService {
|
|
|
|
|
this.cacheActiveGroups();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static getLastChangedActive(): string[] {
|
|
|
|
|
try {
|
|
|
|
|
return Array.from(this._lastChangedActive || []);
|
|
|
|
|
} catch {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static startGroupsScheduler(): void {
|
|
|
|
|
if (process.env.NODE_ENV === 'test') return;
|
|
|
|
|
if (this._groupsSchedulerRunning) return;
|
|
|
|
|
|