|
@@ -116,7 +116,8 @@ export class StatsAggregationScheduler implements OnModuleInit {
|
|
|
const nowSec = Math.floor(Date.now() / 1000);
|
|
const nowSec = Math.floor(Date.now() / 1000);
|
|
|
const effectiveNowSec = nowSec - this.runDelaySec;
|
|
const effectiveNowSec = nowSec - this.runDelaySec;
|
|
|
|
|
|
|
|
- const { fromSec, toSec } = this.prevHourWindow(effectiveNowSec);
|
|
|
|
|
|
|
+ const toSec = this.floorToHour(effectiveNowSec);
|
|
|
|
|
+ const fromSec = toSec - 3600;
|
|
|
const tag = `⏰ Hourly aggregation [${fromSec},${toSec})`;
|
|
const tag = `⏰ Hourly aggregation [${fromSec},${toSec})`;
|
|
|
|
|
|
|
|
this.logger.log(`${tag} start`);
|
|
this.logger.log(`${tag} start`);
|
|
@@ -180,10 +181,14 @@ export class StatsAggregationScheduler implements OnModuleInit {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const nowSec = Math.floor(Date.now() / 1000);
|
|
|
|
|
+ const yesterdayStartSec = this.floorToDayGmt8(nowSec) - 86400;
|
|
|
|
|
+ const yesterdayEndSec = yesterdayStartSec + 86400;
|
|
|
|
|
+ const tag = `🗓️ Daily catch-all (GMT+8) [${yesterdayStartSec},${yesterdayEndSec})`;
|
|
|
|
|
+
|
|
|
if (!this.hasDailyRefresh(this.statsAggregation)) {
|
|
if (!this.hasDailyRefresh(this.statsAggregation)) {
|
|
|
- // No-op if your service doesn’t support daily refresh yet
|
|
|
|
|
this.logger.warn(
|
|
this.logger.warn(
|
|
|
- 'ℹ️ Daily catch-all skipped: refreshDailyDerivedFromHourly not implemented',
|
|
|
|
|
|
|
+ `${tag} skipped: refreshDailyDerivedFromHourly not implemented`,
|
|
|
);
|
|
);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -191,12 +196,6 @@ export class StatsAggregationScheduler implements OnModuleInit {
|
|
|
this.runningDaily = true;
|
|
this.runningDaily = true;
|
|
|
const startedAt = Date.now();
|
|
const startedAt = Date.now();
|
|
|
|
|
|
|
|
- // Refresh “yesterday” (GMT+8 aligned) to catch late events
|
|
|
|
|
- const nowSec = Math.floor(Date.now() / 1000);
|
|
|
|
|
- const yesterdayStartSec = this.floorToDayGmt8(nowSec) - 86400;
|
|
|
|
|
- const yesterdayEndSec = yesterdayStartSec + 86400;
|
|
|
|
|
- const tag = `🗓️ Daily catch-all (GMT+8) [${yesterdayStartSec},${yesterdayEndSec})`;
|
|
|
|
|
-
|
|
|
|
|
this.logger.log(`${tag} start`);
|
|
this.logger.log(`${tag} start`);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -218,11 +217,6 @@ export class StatsAggregationScheduler implements OnModuleInit {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private prevHourWindow(nowSec: number): { fromSec: number; toSec: number } {
|
|
|
|
|
- const endSec = this.floorToHour(nowSec);
|
|
|
|
|
- return { fromSec: endSec - 3600, toSec: endSec };
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private floorToHour(sec: number): number {
|
|
private floorToHour(sec: number): number {
|
|
|
return sec - (sec % 3600);
|
|
return sec - (sec % 3600);
|
|
|
}
|
|
}
|