Skip to content

Commit 0ae2742

Browse files
committed
fix filters
1 parent 49fa583 commit 0ae2742

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/lib/data.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,18 @@ export function getFields(graph: RetinaGraph, type: "node" | "edge", hasEdges: b
383383
}];
384384
}
385385

386+
// Special handling for contributors and stargazers: always content type for search filtering
387+
if (key === "contributors" || key === "stargazers") {
388+
return [{
389+
type: "content",
390+
id: minimized[key],
391+
rawFieldId: key,
392+
label: key === "contributors" ? "contributors" : "stargazers",
393+
typeLabel: undefined,
394+
nullValuesCount: totalRowsCount - values.length,
395+
}];
396+
}
397+
386398
const types =
387399
key.indexOf(RETINA_NUMBER_FIELD_PREFIX) === 0
388400
? (["quanti"] as FieldType[])
@@ -505,6 +517,10 @@ export function countTerms(graph: RetinaGraph, field: Field, nodes?: string[] |
505517
v.split('|').map(t => t.trim()).filter(Boolean).forEach(topic => {
506518
counts[topic] = (counts[topic] || 0) + 1;
507519
});
520+
} else if ((field.rawFieldId === 'contributors' || field.rawFieldId === 'stargazers') && typeof v === 'string') {
521+
v.split(',').map(t => t.trim()).filter(Boolean).forEach(item => {
522+
counts[item] = (counts[item] || 0) + 1;
523+
});
508524
} else if (!isNil(v)) {
509525
counts[v] = (counts[v] || 0) + 1;
510526
}
@@ -551,8 +567,20 @@ export function filterNode(nodeData: NodeData, filters: Filter[], fieldsIndex: R
551567
const topicsArr = value.split('|').map(t => t.trim()).filter(Boolean);
552568
return filter.values.some(val => topicsArr.includes(val));
553569
}
570+
if ((field.rawFieldId === 'contributors' || field.rawFieldId === 'stargazers') && typeof value === 'string') {
571+
const values = value.split(',').map(v => v.trim()).filter(Boolean);
572+
return filter.values.some(val => values.includes(val));
573+
}
554574
return !isNil(value) && filter.values.includes(value + "");
555575
case "search":
576+
if (field.rawFieldId === 'contributors' || field.rawFieldId === 'stargazers') {
577+
// For contributors and stargazers, search within comma-separated values
578+
if (typeof value === 'string') {
579+
const values = value.split(',').map(v => v.trim()).filter(Boolean);
580+
return values.some(v => normalize(v).includes(filter.normalizedValue));
581+
}
582+
return false;
583+
}
556584
return value && normalize(value).includes(filter.normalizedValue);
557585
default:
558586
return false;

0 commit comments

Comments
 (0)