mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-18 11:36:44 +08:00
### What problem does this PR solve? Feat: Filter document by running status and file type. #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
34 lines
803 B
TypeScript
34 lines
803 B
TypeScript
import { DocumentParserType } from '@/constants/knowledge';
|
|
|
|
export function isKnowledgeGraphParser(parserId: DocumentParserType) {
|
|
return parserId === DocumentParserType.KnowledgeGraph;
|
|
}
|
|
|
|
export function isNaiveParser(parserId: DocumentParserType) {
|
|
return parserId === DocumentParserType.Naive;
|
|
}
|
|
|
|
export type FilterType = {
|
|
id: string;
|
|
label: string;
|
|
count: number;
|
|
};
|
|
|
|
export function groupListByType<T extends Record<string, any>>(
|
|
list: T[],
|
|
idField: string,
|
|
labelField: string,
|
|
) {
|
|
const fileTypeList: FilterType[] = [];
|
|
list.forEach((x) => {
|
|
const item = fileTypeList.find((y) => y.id === x[idField]);
|
|
if (!item) {
|
|
fileTypeList.push({ id: x[idField], label: x[labelField], count: 1 });
|
|
} else {
|
|
item.count += 1;
|
|
}
|
|
});
|
|
|
|
return fileTypeList;
|
|
}
|