mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-02-13 20:15:46 +01:00
fix: comprehensive TypeScript/build fixes and modernization
- Update tsconfig to ES2024 target and bundler moduleResolution - Add dynamic imports for chart.js and recharts (bundle optimization) - Consolidate 17 useState into useReducer in sessions page - Fix 18 .js extension imports across lib files - Add type declarations for @rapideditor/country-coder - Fix platform user types (PlatformUserRole enum) - Fix Calendar component prop types - Centralize next-auth type augmentation - Add force-dynamic to all API routes (prevent build-time prerender) - Fix Prisma JSON null handling with Prisma.DbNull - Fix various type mismatches (SessionMessage, ImportRecord, etc.) - Export ButtonProps from button component - Update next-themes import path - Replace JSX.Element with React.ReactElement - Remove obsolete debug scripts and pnpm lockfile - Downgrade eslint to v8 for next compatibility
This commit is contained in:
@@ -7,14 +7,14 @@ import {
|
||||
} from "@prisma/client";
|
||||
import cron from "node-cron";
|
||||
import fetch from "node-fetch";
|
||||
import { withRetry } from "./database-retry.js";
|
||||
import { prisma } from "./prisma.js";
|
||||
import { withRetry } from "./database-retry";
|
||||
import { prisma } from "./prisma";
|
||||
import {
|
||||
completeStage,
|
||||
failStage,
|
||||
getSessionsNeedingProcessing,
|
||||
startStage,
|
||||
} from "./processingStatusManager.js";
|
||||
} from "./processingStatusManager";
|
||||
import { getSchedulerConfig } from "./schedulerConfig";
|
||||
|
||||
const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
|
||||
@@ -137,14 +137,18 @@ interface ProcessingResult {
|
||||
|
||||
interface SessionMessage {
|
||||
id: string;
|
||||
timestamp: Date;
|
||||
sessionId: string;
|
||||
timestamp: Date | null;
|
||||
role: string;
|
||||
content: string;
|
||||
order: number;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
interface SessionForProcessing {
|
||||
id: string;
|
||||
companyId: string;
|
||||
endTime: Date;
|
||||
messages: SessionMessage[];
|
||||
}
|
||||
|
||||
@@ -250,7 +254,9 @@ async function processQuestions(
|
||||
});
|
||||
|
||||
// Filter and prepare unique questions
|
||||
const uniqueQuestions = [...new Set(questions.filter((q) => q.trim()))];
|
||||
const uniqueQuestions = Array.from(
|
||||
new Set(questions.filter((q) => q.trim()))
|
||||
);
|
||||
if (uniqueQuestions.length === 0) return;
|
||||
|
||||
// Batch create questions (skip duplicates)
|
||||
@@ -527,7 +533,7 @@ async function processSingleSession(
|
||||
const transcript = session.messages
|
||||
.map(
|
||||
(msg: SessionMessage) =>
|
||||
`[${new Date(msg.timestamp)
|
||||
`[${new Date(msg.timestamp ?? msg.createdAt)
|
||||
.toLocaleString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
@@ -710,9 +716,8 @@ async function processUnprocessedSessionsInternal(
|
||||
|
||||
// Filter to only sessions that have messages
|
||||
const sessionsWithMessages = sessionsToProcess.filter(
|
||||
(session): session is SessionForProcessing =>
|
||||
session.messages && session.messages.length > 0
|
||||
);
|
||||
(session) => session.messages && session.messages.length > 0
|
||||
) as SessionForProcessing[];
|
||||
|
||||
if (sessionsWithMessages.length === 0) {
|
||||
process.stdout.write(
|
||||
|
||||
Reference in New Issue
Block a user