Backfill activity experience from form notes so list and filters work.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1559,6 +1559,30 @@ export function isActivityExperienceLabel(label: string): boolean {
|
||||
return /سابقه\s*فعالیت/.test(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* استخراج سابقه فعالیت از خطوط یادداشت فرم
|
||||
* (مثلاً «سابقه فعالیت در حوزه نقره: بیش از 5 سال»).
|
||||
*/
|
||||
export function extractActivityExperienceFromNotes(
|
||||
notes: string | null | undefined,
|
||||
): ActivityExperience | null {
|
||||
const text = (notes ?? "").trim();
|
||||
if (!text || !/سابقه\s*فعالیت/.test(text.replace(/ي/g, "ی").replace(/ك/g, "ک"))) {
|
||||
return null;
|
||||
}
|
||||
for (const line of text.split(/\r?\n/)) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) continue;
|
||||
const splitAt = trimmed.indexOf(":");
|
||||
if (splitAt <= 0 || splitAt > 200) continue;
|
||||
const label = trimmed.slice(0, splitAt).trim();
|
||||
const value = trimmed.slice(splitAt + 1).trim();
|
||||
if (!value || !isActivityExperienceLabel(label)) continue;
|
||||
return normalizeActivityExperience(value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export interface PersonImportSourceStatDto {
|
||||
source: PersonImportSource | string;
|
||||
label: string;
|
||||
|
||||
Reference in New Issue
Block a user