From 77f7927e77ee1d4ffa5d0d356af7c3eef6ecf7c5 Mon Sep 17 00:00:00 2001 From: DaKheera47 Date: Wed, 21 Jan 2026 15:30:45 +0000 Subject: [PATCH] honour profilePath --- .../src/server/pipeline/orchestrator.ts | 22 ++++++++++++------- orchestrator/src/server/services/profile.ts | 14 ++++++++---- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/orchestrator/src/server/pipeline/orchestrator.ts b/orchestrator/src/server/pipeline/orchestrator.ts index bdce8cc..c79448b 100644 --- a/orchestrator/src/server/pipeline/orchestrator.ts +++ b/orchestrator/src/server/pipeline/orchestrator.ts @@ -113,7 +113,7 @@ export async function runPipeline(config: Partial = {}): Promise try { // Step 1: Load profile console.log('\nšŸ“‹ Loading profile...'); - const profile = await getProfile(); + const profile = await getProfile(mergedConfig.profilePath); // Step 2: Run crawler console.log('\nšŸ•·ļø Running crawler...'); @@ -347,7 +347,7 @@ export async function runPipeline(config: Partial = {}): Promise // Process job (Generate Summary + PDF) // We catch errors here to ensure one failure doesn't stop the whole batch - const result = await processJob(job.id); + const result = await processJob(job.id, { profilePath: mergedConfig.profilePath }); if (result.success) { processedCount++; @@ -414,12 +414,17 @@ export async function runPipeline(config: Partial = {}): Promise } } +export type ProcessJobOptions = { + force?: boolean; + profilePath?: string; +}; + /** * Step 1: Generate AI summary and suggest projects. */ export async function summarizeJob( jobId: string, - options?: { force?: boolean } + options?: ProcessJobOptions ): Promise<{ success: boolean; error?: string; @@ -430,7 +435,7 @@ export async function summarizeJob( const job = await jobsRepo.getJobById(jobId); if (!job) return { success: false, error: 'Job not found' }; - const profile = await getProfile(); + const profile = await getProfile(options?.profilePath); // 1. Generate Summary & Tailoring let tailoredSummary = job.tailoredSummary; @@ -491,7 +496,8 @@ export async function summarizeJob( * Step 2: Generate PDF using current summary and project selection. */ export async function generateFinalPdf( - jobId: string + jobId: string, + options?: ProcessJobOptions ): Promise<{ success: boolean; error?: string; @@ -513,7 +519,7 @@ export async function generateFinalPdf( skills: job.tailoredSkills ? JSON.parse(job.tailoredSkills) : [] }, job.jobDescription || '', - DEFAULT_PROFILE_PATH, + options?.profilePath || DEFAULT_PROFILE_PATH, job.selectedProjectIds ); @@ -540,7 +546,7 @@ export async function generateFinalPdf( */ export async function processJob( jobId: string, - options?: { force?: boolean } + options?: ProcessJobOptions ): Promise<{ success: boolean; error?: string; @@ -551,7 +557,7 @@ export async function processJob( if (!sumResult.success) return sumResult; // Step 2: Generate PDF - const pdfResult = await generateFinalPdf(jobId); + const pdfResult = await generateFinalPdf(jobId, options); return pdfResult; } catch (error) { diff --git a/orchestrator/src/server/services/profile.ts b/orchestrator/src/server/services/profile.ts index 07d929b..36a3d2a 100644 --- a/orchestrator/src/server/services/profile.ts +++ b/orchestrator/src/server/services/profile.ts @@ -6,22 +6,28 @@ const __dirname = dirname(fileURLToPath(import.meta.url)); const DEFAULT_PROFILE_PATH = join(__dirname, '../../../../resume-generator/base.json'); let cachedProfile: any = null; +let cachedProfilePath: string | null = null; /** * Get the base resume profile from base.json. * Caches the result since it doesn't change often. + * @param profilePath Optional absolute path to profile JSON. Defaults to base.json. + * @param forceRefresh Force reload from disk. */ -export async function getProfile(forceRefresh = false): Promise { - if (cachedProfile && !forceRefresh) { +export async function getProfile(profilePath?: string, forceRefresh = false): Promise { + const targetPath = profilePath || DEFAULT_PROFILE_PATH; + + if (cachedProfile && cachedProfilePath === targetPath && !forceRefresh) { return cachedProfile; } try { - const content = await readFile(DEFAULT_PROFILE_PATH, 'utf-8'); + const content = await readFile(targetPath, 'utf-8'); cachedProfile = JSON.parse(content); + cachedProfilePath = targetPath; return cachedProfile; } catch (error) { - console.error('āŒ Failed to load profile from base.json:', error); + console.error(`āŒ Failed to load profile from ${targetPath}:`, error); return {}; } }