Implementation:Infiniflow Ragflow List Filter Util
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Frontend, Utilities, Data_Processing |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Concrete generic list grouping and counting algorithms for filtering UI data in the RAGFlow frontend.
Description
The utils/list-filter-util.ts module provides functions for grouping items by a specified field, counting occurrences of distinct values, and building filter option lists from data arrays.
Usage
Import these utilities when building filter dropdowns that need to show count badges or group items by category.
Code Reference
Source Location
- Repository: Infiniflow_Ragflow
- File: web/src/utils/list-filter-util.ts
- Lines: 1-53
Signature
export function groupByField<T>(items: T[], field: keyof T): Record<string, T[]>;
export function countByField<T>(items: T[], field: keyof T): Record<string, number>;
export function buildFilterOptions<T>(items: T[], field: keyof T): FilterOption[];
Import
import { groupByField, countByField } from '@/utils/list-filter-util';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| items | T[] | Yes | Array of items to group |
| field | keyof T | Yes | Field name to group by |
Outputs
| Name | Type | Description |
|---|---|---|
| groupByField() | Record | Items grouped by field value |
| countByField() | Record | Count of items per field value |
Usage Examples
import { countByField } from '@/utils/list-filter-util';
const statusCounts = countByField(documents, 'status');
// { completed: 15, processing: 3, failed: 1 }
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment