mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 19:52:09 +01:00
refactor: achieve 100% biome compliance with comprehensive code quality improvements
- Fix all cognitive complexity violations (63→0 errors) - Replace 'any' types with proper TypeScript interfaces and generics - Extract helper functions and custom hooks to reduce complexity - Fix React hook dependency arrays and useCallback patterns - Remove unused imports, variables, and functions - Implement proper formatting across all files - Add type safety with interfaces like AIProcessingRequestWithSession - Fix circuit breaker implementation with proper reset() method - Resolve all accessibility and form labeling issues - Clean up mysterious './0' file containing biome output Total: 63 errors → 0 errors, 42 warnings → 0 warnings
This commit is contained in:
@ -122,7 +122,7 @@ export async function getPendingBatchRequestsOptimized(
|
||||
}
|
||||
);
|
||||
|
||||
return requests as any; // Type assertion since we're only including essential data
|
||||
return requests;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +168,7 @@ export async function getPendingBatchRequestsForAllCompanies(): Promise<
|
||||
if (!requestsByCompany.has(companyId)) {
|
||||
requestsByCompany.set(companyId, []);
|
||||
}
|
||||
requestsByCompany.get(companyId)?.push(request as any);
|
||||
requestsByCompany.get(companyId)?.push(request);
|
||||
}
|
||||
|
||||
const duration = Date.now() - startTime;
|
||||
@ -190,7 +190,7 @@ export async function getPendingBatchRequestsForAllCompanies(): Promise<
|
||||
* Optimized batch status checking for all companies
|
||||
*/
|
||||
export async function getInProgressBatchesForAllCompanies(): Promise<
|
||||
Map<string, any[]>
|
||||
Map<string, unknown[]>
|
||||
> {
|
||||
const startTime = Date.now();
|
||||
const companies = await companyCache.getActiveCompanies();
|
||||
@ -221,7 +221,7 @@ export async function getInProgressBatchesForAllCompanies(): Promise<
|
||||
});
|
||||
|
||||
// Group by company
|
||||
const batchesByCompany = new Map<string, any[]>();
|
||||
const batchesByCompany = new Map<string, unknown[]>();
|
||||
for (const batch of allBatches) {
|
||||
if (!batchesByCompany.has(batch.companyId)) {
|
||||
batchesByCompany.set(batch.companyId, []);
|
||||
@ -248,7 +248,7 @@ export async function getInProgressBatchesForAllCompanies(): Promise<
|
||||
* Optimized completed batch processing for all companies
|
||||
*/
|
||||
export async function getCompletedBatchesForAllCompanies(): Promise<
|
||||
Map<string, any[]>
|
||||
Map<string, unknown[]>
|
||||
> {
|
||||
const startTime = Date.now();
|
||||
const companies = await companyCache.getActiveCompanies();
|
||||
@ -283,7 +283,7 @@ export async function getCompletedBatchesForAllCompanies(): Promise<
|
||||
});
|
||||
|
||||
// Group by company
|
||||
const batchesByCompany = new Map<string, any[]>();
|
||||
const batchesByCompany = new Map<string, unknown[]>();
|
||||
for (const batch of allBatches) {
|
||||
if (!batchesByCompany.has(batch.companyId)) {
|
||||
batchesByCompany.set(batch.companyId, []);
|
||||
@ -349,9 +349,10 @@ export async function getFailedRequestsForAllCompanies(
|
||||
requestsByCompany.set(companyId, []);
|
||||
}
|
||||
|
||||
const companyRequests = requestsByCompany.get(companyId)!;
|
||||
const companyRequests = requestsByCompany.get(companyId);
|
||||
if (!companyRequests) continue;
|
||||
if (companyRequests.length < maxPerCompany) {
|
||||
companyRequests.push(request as any);
|
||||
companyRequests.push(request);
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,7 +413,13 @@ export async function getOldestPendingRequestOptimized(
|
||||
*/
|
||||
export async function getBatchProcessingStatsOptimized(
|
||||
companyId?: string
|
||||
): Promise<any> {
|
||||
): Promise<{
|
||||
totalBatches: number;
|
||||
pendingRequests: number;
|
||||
inProgressBatches: number;
|
||||
completedBatches: number;
|
||||
failedRequests: number;
|
||||
}> {
|
||||
const startTime = Date.now();
|
||||
|
||||
const whereClause = companyId ? { companyId } : {};
|
||||
|
||||
Reference in New Issue
Block a user