chore: code cleanup - remove duplicates and add caching
- Delete duplicate getCacheStats() function in cache.service.js - Fix date calculation bug in lotw.service.js (was Date.now()-Date.now()) - Extract duplicate helper functions (yieldToEventLoop, getQSOKey) to sync-helpers.js - Cache award definitions in memory to avoid repeated file I/O - Delete unused parseDCLJSONResponse() function - Remove unused imports (getPerformanceSummary, resetPerformanceMetrics) - Auto-discover award JSON files instead of hardcoded list Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -86,32 +86,6 @@ export function clearAllCache() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache statistics (for monitoring/debugging)
|
||||
* @returns {object} Cache stats
|
||||
*/
|
||||
export function getCacheStats() {
|
||||
const now = Date.now();
|
||||
let expired = 0;
|
||||
let valid = 0;
|
||||
|
||||
for (const [, value] of awardCache) {
|
||||
const age = now - value.timestamp;
|
||||
if (age > CACHE_TTL) {
|
||||
expired++;
|
||||
} else {
|
||||
valid++;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
total: awardCache.size,
|
||||
valid,
|
||||
expired,
|
||||
ttl: CACHE_TTL
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up expired cache entries (maintenance function)
|
||||
* Can be called periodically to free memory
|
||||
|
||||
Reference in New Issue
Block a user