fix
This commit is contained in:
@@ -503,9 +503,17 @@ export class AgentsService {
|
||||
|
||||
const matchingIds = matchingValues
|
||||
.filter((fv) => {
|
||||
const jsonVal = fv.jsonValue as string[] | null;
|
||||
if (!jsonVal || !Array.isArray(jsonVal)) return false;
|
||||
return selectedValues.some((sv) => jsonVal.includes(sv));
|
||||
const jsonVal = fv.jsonValue as unknown;
|
||||
if (!Array.isArray(jsonVal)) return false;
|
||||
// Direct match (normalized option values stored in jsonVal)
|
||||
if (selectedValues.some((sv) => jsonVal.includes(sv))) return true;
|
||||
// TAG_INPUT fallback: strip " - N yrs" suffix and normalize
|
||||
const normalized = (jsonVal as unknown[])
|
||||
.map((item) => typeof item === 'string' ? item : '')
|
||||
.map((s) => s.replace(/\s*[-–]\s*\d+\s*(yrs?|years?)\s*$/i, '').trim())
|
||||
.map((s) => s.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, ''))
|
||||
.filter(Boolean);
|
||||
return selectedValues.some((sv) => normalized.includes(sv));
|
||||
})
|
||||
.map((fv) => fv.agentProfileId);
|
||||
|
||||
@@ -664,11 +672,17 @@ export class AgentsService {
|
||||
const agentFieldValues = (agent.fieldValues || []) as any[];
|
||||
const fieldMatch = agentFieldValues.some((fv: any) => {
|
||||
if (fv.field?.slug !== filterSlug) return false;
|
||||
const jsonVal = fv.jsonValue as string[] | null;
|
||||
if (jsonVal && Array.isArray(jsonVal)) {
|
||||
return selectedValues.some(sv => jsonVal.includes(sv));
|
||||
}
|
||||
return false;
|
||||
const jsonVal = fv.jsonValue as unknown;
|
||||
if (!Array.isArray(jsonVal)) return false;
|
||||
// Direct match (normalized option values already stored in jsonVal)
|
||||
if (selectedValues.some(sv => jsonVal.includes(sv))) return true;
|
||||
// TAG_INPUT fallback: strip " - N yrs" suffix and normalize to match aggregated expertise values
|
||||
const normalized = (jsonVal as unknown[])
|
||||
.map((item) => typeof item === 'string' ? item : '')
|
||||
.map((s) => s.replace(/\s*[-–]\s*\d+\s*(yrs?|years?)\s*$/i, '').trim())
|
||||
.map((s) => s.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, ''))
|
||||
.filter(Boolean);
|
||||
return selectedValues.some(sv => normalized.includes(sv));
|
||||
});
|
||||
if (fieldMatch) matchedFilters++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user