honour profilePath
This commit is contained in:
parent
7c524f5d63
commit
77f7927e77
@ -113,7 +113,7 @@ export async function runPipeline(config: Partial<PipelineConfig> = {}): 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<PipelineConfig> = {}): 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<PipelineConfig> = {}): 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) {
|
||||
|
||||
@ -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<any> {
|
||||
if (cachedProfile && !forceRefresh) {
|
||||
export async function getProfile(profilePath?: string, forceRefresh = false): Promise<any> {
|
||||
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 {};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user