mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 11:32:13 +01:00
feat: implement cache layer, CSP improvements, and database performance optimizations
- Add Redis cache implementation with LRU eviction - Enhance Content Security Policy with nonce generation - Optimize database queries with connection pooling - Add cache invalidation API endpoints - Improve security monitoring performance
This commit is contained in:
@ -90,6 +90,13 @@ class PerformanceTracker {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.metrics = {
|
||||
optimized: { totalTime: 0, operationCount: 0, errorCount: 0 },
|
||||
original: { totalTime: 0, operationCount: 0, errorCount: 0 },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const performanceTracker = new PerformanceTracker();
|
||||
@ -205,7 +212,30 @@ export const IntegratedBatchProcessor = {
|
||||
getBatchProcessingStats: async (companyId?: string) => {
|
||||
return executeWithTracking(
|
||||
() => OptimizedProcessor.getBatchProcessingStatsOptimized(companyId),
|
||||
() => OriginalProcessor.getBatchProcessingStats(companyId || ""),
|
||||
async () => {
|
||||
// Adapter function to transform original output to match optimized output
|
||||
const originalResult = await OriginalProcessor.getBatchProcessingStats(
|
||||
companyId || ""
|
||||
);
|
||||
const batchStats = originalResult.batchStats as Record<string, number>;
|
||||
|
||||
return {
|
||||
totalBatches: Object.values(batchStats).reduce(
|
||||
(sum, count) => sum + count,
|
||||
0
|
||||
),
|
||||
pendingRequests: originalResult.pendingRequests,
|
||||
inProgressBatches:
|
||||
(batchStats["IN_PROGRESS"] || 0) +
|
||||
(batchStats["VALIDATING"] || 0) +
|
||||
(batchStats["UPLOADING"] || 0) +
|
||||
(batchStats["FINALIZING"] || 0),
|
||||
completedBatches:
|
||||
(batchStats["COMPLETED"] || 0) + (batchStats["PROCESSED"] || 0),
|
||||
failedRequests:
|
||||
(batchStats["FAILED"] || 0) + (batchStats["CANCELLED"] || 0),
|
||||
};
|
||||
},
|
||||
"getBatchProcessingStats"
|
||||
);
|
||||
},
|
||||
@ -303,10 +333,7 @@ export const IntegratedBatchProcessor = {
|
||||
* Reset performance tracking (useful for testing)
|
||||
*/
|
||||
resetPerformanceTracking: (): void => {
|
||||
performanceTracker.metrics = {
|
||||
optimized: { totalTime: 0, operationCount: 0, errorCount: 0 },
|
||||
original: { totalTime: 0, operationCount: 0, errorCount: 0 },
|
||||
};
|
||||
performanceTracker.reset();
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user