mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 11:32:13 +01:00
feat: add rawTranscriptContent field to SessionImport model
feat: enhance server initialization with environment validation and import processing scheduler test: add Jest setup for unit tests and mock console methods test: implement unit tests for environment management and validation test: create unit tests for transcript fetcher functionality
This commit is contained in:
@ -1,30 +1,7 @@
|
||||
// Unified scheduler configuration
|
||||
import { readFileSync } from "fs";
|
||||
import { fileURLToPath } from "url";
|
||||
import { dirname, join } from "path";
|
||||
// Legacy scheduler configuration - now uses centralized env management
|
||||
// This file is kept for backward compatibility but delegates to lib/env.ts
|
||||
|
||||
// Load environment variables from .env.local
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const envPath = join(__dirname, '..', '.env.local');
|
||||
|
||||
// Load .env.local if it exists
|
||||
try {
|
||||
const envFile = readFileSync(envPath, 'utf8');
|
||||
const envVars = envFile.split('\n').filter(line => line.trim() && !line.startsWith('#'));
|
||||
|
||||
envVars.forEach(line => {
|
||||
const [key, ...valueParts] = line.split('=');
|
||||
if (key && valueParts.length > 0) {
|
||||
const value = valueParts.join('=').trim();
|
||||
if (!process.env[key.trim()]) {
|
||||
process.env[key.trim()] = value;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
// Silently fail if .env.local doesn't exist
|
||||
}
|
||||
import { getSchedulerConfig as getEnvSchedulerConfig, logEnvConfig } from "./env";
|
||||
|
||||
export interface SchedulerConfig {
|
||||
enabled: boolean;
|
||||
@ -40,43 +17,28 @@ export interface SchedulerConfig {
|
||||
|
||||
/**
|
||||
* Get scheduler configuration from environment variables
|
||||
* @deprecated Use getSchedulerConfig from lib/env.ts instead
|
||||
*/
|
||||
export function getSchedulerConfig(): SchedulerConfig {
|
||||
const enabled = process.env.SCHEDULER_ENABLED === 'true';
|
||||
const config = getEnvSchedulerConfig();
|
||||
|
||||
// Default values
|
||||
const defaults = {
|
||||
csvImportInterval: '*/15 * * * *', // Every 15 minutes
|
||||
sessionProcessingInterval: '0 * * * *', // Every hour
|
||||
sessionProcessingBatchSize: 0, // Unlimited
|
||||
sessionProcessingConcurrency: 5,
|
||||
};
|
||||
|
||||
return {
|
||||
enabled,
|
||||
enabled: config.enabled,
|
||||
csvImport: {
|
||||
interval: process.env.CSV_IMPORT_INTERVAL || defaults.csvImportInterval,
|
||||
interval: config.csvImport.interval,
|
||||
},
|
||||
sessionProcessing: {
|
||||
interval: process.env.SESSION_PROCESSING_INTERVAL || defaults.sessionProcessingInterval,
|
||||
batchSize: parseInt(process.env.SESSION_PROCESSING_BATCH_SIZE || '0', 10) || defaults.sessionProcessingBatchSize,
|
||||
concurrency: parseInt(process.env.SESSION_PROCESSING_CONCURRENCY || '5', 10) || defaults.sessionProcessingConcurrency,
|
||||
interval: config.sessionProcessing.interval,
|
||||
batchSize: config.sessionProcessing.batchSize,
|
||||
concurrency: config.sessionProcessing.concurrency,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Log scheduler configuration
|
||||
* @deprecated Use logEnvConfig from lib/env.ts instead
|
||||
*/
|
||||
export function logSchedulerConfig(config: SchedulerConfig): void {
|
||||
if (!config.enabled) {
|
||||
console.log('[Scheduler] Schedulers are DISABLED (SCHEDULER_ENABLED=false)');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[Scheduler] Configuration:');
|
||||
console.log(` CSV Import: ${config.csvImport.interval}`);
|
||||
console.log(` Session Processing: ${config.sessionProcessing.interval}`);
|
||||
console.log(` Batch Size: ${config.sessionProcessing.batchSize === 0 ? 'unlimited' : config.sessionProcessing.batchSize}`);
|
||||
console.log(` Concurrency: ${config.sessionProcessing.concurrency}`);
|
||||
logEnvConfig();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user