mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 09:32:08 +01:00
feat: comprehensive Biome linting fixes and code quality improvements
Major code quality overhaul addressing 58% of all linting issues: • Type Safety Improvements: - Replace all any types with proper TypeScript interfaces - Fix Map component shadowing (renamed to CountryMap) - Add comprehensive custom error classes system - Enhance API route type safety • Accessibility Enhancements: - Add explicit button types to all interactive elements - Implement useId() hooks for form element accessibility - Add SVG title attributes for screen readers - Fix static element interactions with keyboard handlers • React Best Practices: - Resolve exhaustive dependencies warnings with useCallback - Extract nested component definitions to top level - Fix array index keys with proper unique identifiers - Improve component organization and prop typing • Code Organization: - Automatic import organization and type import optimization - Fix unused function parameters and variables - Enhanced error handling with structured error responses - Improve component reusability and maintainability Results: 248 → 104 total issues (58% reduction) - Fixed all critical type safety and security issues - Enhanced accessibility compliance significantly - Improved code maintainability and performance
This commit is contained in:
@ -1,14 +1,15 @@
|
||||
// Enhanced session processing scheduler with AI cost tracking and question management
|
||||
import cron from "node-cron";
|
||||
|
||||
import {
|
||||
PrismaClient,
|
||||
SentimentCategory,
|
||||
SessionCategory,
|
||||
ProcessingStage,
|
||||
type SentimentCategory,
|
||||
type SessionCategory,
|
||||
} from "@prisma/client";
|
||||
import cron from "node-cron";
|
||||
import fetch from "node-fetch";
|
||||
import { getSchedulerConfig } from "./schedulerConfig";
|
||||
import { ProcessingStatusManager } from "./processingStatusManager";
|
||||
import { getSchedulerConfig } from "./schedulerConfig";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
|
||||
@ -201,32 +202,30 @@ async function processQuestions(
|
||||
});
|
||||
|
||||
// Filter and prepare unique questions
|
||||
const uniqueQuestions = [...new Set(questions.filter(q => q.trim()))];
|
||||
const uniqueQuestions = [...new Set(questions.filter((q) => q.trim()))];
|
||||
if (uniqueQuestions.length === 0) return;
|
||||
|
||||
// Batch create questions (skip duplicates)
|
||||
await prisma.question.createMany({
|
||||
data: uniqueQuestions.map(content => ({ content: content.trim() })),
|
||||
data: uniqueQuestions.map((content) => ({ content: content.trim() })),
|
||||
skipDuplicates: true,
|
||||
});
|
||||
|
||||
// Fetch all question IDs in one query
|
||||
const existingQuestions = await prisma.question.findMany({
|
||||
where: { content: { in: uniqueQuestions.map(q => q.trim()) } },
|
||||
where: { content: { in: uniqueQuestions.map((q) => q.trim()) } },
|
||||
select: { id: true, content: true },
|
||||
});
|
||||
|
||||
// Create a map for quick lookup
|
||||
const questionMap = new Map(
|
||||
existingQuestions.map(q => [q.content, q.id])
|
||||
);
|
||||
const questionMap = new Map(existingQuestions.map((q) => [q.content, q.id]));
|
||||
|
||||
// Prepare session questions data
|
||||
const sessionQuestionsData = questions
|
||||
.map((questionText, index) => {
|
||||
const trimmed = questionText.trim();
|
||||
if (!trimmed) return null;
|
||||
|
||||
|
||||
const questionId = questionMap.get(trimmed);
|
||||
if (!questionId) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user