fix(usage): Debugging issue with usage tracking

This commit is contained in:
Chris Troutner
2025-05-18 15:36:32 -07:00
parent 354321c956
commit e6317c3282
3 changed files with 15 additions and 5 deletions
+5 -2
View File
@@ -1,6 +1,6 @@
/*
This Controller library is concerned with timer-based functions that are
kicked off periodicially.
kicked off periodically.
*/
import config from '../../config/index.js'
@@ -45,7 +45,7 @@ class TimerControllers {
stopTimers () {
clearInterval(this.optimizeWalletHandle)
clearInterval(this.cleanusageHandle)
clearInterval(this.cleanUsageHandle)
}
// Replace this example function with your own timer handler.
@@ -67,6 +67,9 @@ class TimerControllers {
// Clean the usage state so that stats reflect the last 24 hours.
cleanUsage () {
try {
const now = new Date()
console.log(`cleanUsage() Timer Controller executing at ${now.toLocaleString()}`)
this.useCases.usage.cleanUsage()
return true
+4
View File
@@ -36,7 +36,11 @@ class UsageUseCases {
const now = new Date()
const twentyFourHoursAgo = now.getTime() - (60000 * 60 * 24)
console.log('cleanUsage() now: ', now)
console.log('cleanUsage() restCalls.length before filtering: ', restCalls.length)
restCalls = restCalls.filter(x => x.timestamp > twentyFourHoursAgo)
console.log('cleanUsage() restCalls.length after filtering: ', restCalls.length)
return restCalls
} catch (err) {
console.error('Error in usage-use-cases.js/cleanUsage()')