mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 09:32:08 +01:00
- Updated formatting in SessionDetails component for better readability. - Enhanced documentation in scheduler-fixes.md to clarify issues and solutions. - Improved error handling and logging in csvFetcher.js and processingScheduler.js. - Standardized code formatting across various scripts and components for consistency. - Added validation checks for CSV URLs and transcript content to prevent processing errors. - Enhanced logging messages for better tracking of processing status and errors.
38 lines
995 B
JavaScript
38 lines
995 B
JavaScript
// Session refresh scheduler - JavaScript version
|
|
import cron from "node-cron";
|
|
import { PrismaClient } from "@prisma/client";
|
|
import { fetchAndStoreSessionsForAllCompanies } from "./csvFetcher.js";
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
/**
|
|
* Refresh sessions for all companies
|
|
*/
|
|
async function refreshSessions() {
|
|
console.log("[Scheduler] Starting session refresh...");
|
|
try {
|
|
await fetchAndStoreSessionsForAllCompanies();
|
|
console.log("[Scheduler] Session refresh completed successfully.");
|
|
} catch (error) {
|
|
console.error("[Scheduler] Error during session refresh:", error);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Start the session refresh scheduler
|
|
*/
|
|
export function startScheduler() {
|
|
// Run every 15 minutes
|
|
cron.schedule("*/15 * * * *", async () => {
|
|
try {
|
|
await refreshSessions();
|
|
} catch (error) {
|
|
console.error("[Scheduler] Error in scheduler:", error);
|
|
}
|
|
});
|
|
|
|
console.log(
|
|
"[Scheduler] Started session refresh scheduler (runs every 15 minutes)."
|
|
);
|
|
}
|