feat: Implement session processing and refresh schedulers

- Added processingScheduler.js and processingScheduler.ts to handle session transcript processing using OpenAI API.
- Implemented a new scheduler (scheduler.js and schedulers.ts) for refreshing sessions every 15 minutes.
- Updated Prisma migrations to add new fields for processed sessions, including questions, sentimentCategory, and summary.
- Created scripts (process_sessions.mjs and process_sessions.ts) for manual processing of unprocessed sessions.
- Enhanced server.js and server.mjs to initialize schedulers on server start.
This commit is contained in:
Max Kowalski
2025-06-25 16:14:01 +02:00
parent c9e24298cd
commit 3196dabdf2
23 changed files with 2267 additions and 49 deletions

38
server.ts Normal file
View File

@ -0,0 +1,38 @@
// Custom Next.js server with scheduler initialization
import { createServer } from 'http';
import { parse } from 'url';
import next from 'next';
import { startScheduler } from './lib/scheduler.js';
import { startProcessingScheduler } from './lib/processingScheduler.js';
const dev = process.env.NODE_ENV !== 'production';
const hostname = 'localhost';
const port = parseInt(process.env.PORT || '3000', 10);
// Initialize Next.js
const app = next({ dev, hostname, port });
const handle = app.getRequestHandler();
app.prepare().then(() => {
// Initialize schedulers when the server starts
console.log('Starting schedulers...');
startScheduler();
startProcessingScheduler();
console.log('All schedulers initialized successfully');
createServer(async (req, res) => {
try {
// Parse the URL
const parsedUrl = parse(req.url || '', true);
// Let Next.js handle the request
await handle(req, res, parsedUrl);
} catch (err) {
console.error('Error occurred handling', req.url, err);
res.statusCode = 500;
res.end('Internal Server Error');
}
}).listen(port, () => {
console.log(`> Ready on http://${hostname}:${port}`);
});
});