Re_Backend/src/config/tat.config.ts

77 lines
2.2 KiB
TypeScript

/**
* TAT (Turnaround Time) Configuration
*
* This file contains configuration for TAT notifications and testing
*/
export const TAT_CONFIG = {
// Working hours configuration
WORK_START_HOUR: parseInt(process.env.WORK_START_HOUR || '9', 10),
WORK_END_HOUR: parseInt(process.env.WORK_END_HOUR || '18', 10),
// Working days (1 = Monday, 5 = Friday)
WORK_START_DAY: 1,
WORK_END_DAY: 5,
// TAT notification thresholds (percentage)
THRESHOLD_50_PERCENT: 50,
THRESHOLD_75_PERCENT: 75,
THRESHOLD_100_PERCENT: 100,
// Testing mode - Set to true for faster notifications in development
TEST_MODE: process.env.TAT_TEST_MODE === 'true',
// In test mode, use minutes instead of hours (1 hour = 1 minute)
TEST_TIME_MULTIPLIER: process.env.TAT_TEST_MODE === 'true' ? 1/60 : 1,
// Redis configuration
REDIS_URL: process.env.REDIS_URL || 'redis://localhost:6379',
// Queue configuration
QUEUE_CONCURRENCY: 5,
QUEUE_RATE_LIMIT_MAX: 10,
QUEUE_RATE_LIMIT_DURATION: 1000,
// Retry configuration
MAX_RETRY_ATTEMPTS: 3,
RETRY_BACKOFF_DELAY: 2000,
};
/**
* Get TAT time in appropriate units based on test mode
* @param hours - TAT hours
* @returns Adjusted time for test mode
*/
export function getTatTime(hours: number): number {
return hours * TAT_CONFIG.TEST_TIME_MULTIPLIER;
}
/**
* Get display name for time unit based on test mode
*/
export function getTimeUnitName(): string {
return TAT_CONFIG.TEST_MODE ? 'minutes' : 'hours';
}
/**
* Check if TAT system is in test mode
*/
export function isTestMode(): boolean {
return TAT_CONFIG.TEST_MODE;
}
/**
* Log TAT configuration on startup
*/
export function logTatConfig(): void {
console.log('⏰ TAT Configuration:');
console.log(` - Test Mode: ${TAT_CONFIG.TEST_MODE ? 'ENABLED (1 hour = 1 minute)' : 'DISABLED'}`);
console.log(` - Working Hours: ${TAT_CONFIG.WORK_START_HOUR}:00 - ${TAT_CONFIG.WORK_END_HOUR}:00`);
console.log(` - Working Days: Monday - Friday`);
console.log(` - Redis: ${TAT_CONFIG.REDIS_URL}`);
console.log(` - Thresholds: ${TAT_CONFIG.THRESHOLD_50_PERCENT}%, ${TAT_CONFIG.THRESHOLD_75_PERCENT}%, ${TAT_CONFIG.THRESHOLD_100_PERCENT}%`);
}
export default TAT_CONFIG;