Introduction to the Filter_Conditions Table
The filter_conditions table is designed to store and manage filter conditions for process steps in the Serial application. This table plays a crucial role in enabling dynamic filtering of data and controlling the visibility of process steps based on specific criteria.Table Structure
The filter_conditions table is structured to capture various aspects of a filter condition, including its associated company, process step, type, and operator. Here’s a detailed breakdown of its columns:| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | Unique identifier for the filter condition |
| company_id | uuid | not null, foreign key | Reference to the associated company |
| process_step_id | uuid | Reference to the associated process step | |
| name | text | not null | Name of the filter condition |
| type | text | not null | Type of the filter condition |
| dataset_id | uuid | Reference to the associated dataset (if applicable) | |
| operator | text | not null | Operator used for the filter condition |
| value | text | not null | Value to compare against in the filter condition |
| label | text | Optional label for the filter condition | |
| created_at | timestamp | not null, default now() | Timestamp of when the filter condition was created |
Usage and Functionality
The filter_conditions table is designed to be flexible and support various types of filtering operations. Here are some key points about its usage:-
Process Step Association: Each filter condition is typically associated with a specific process step through the
process_step_idcolumn. This allows for step-specific filtering within a process. -
Company-Specific Filtering: The
company_idcolumn ensures that filter conditions are segregated by company, allowing for company-specific configurations. -
Flexible Condition Types: The
typecolumn allows for different types of filter conditions, which can be used to filter various data types such as numeric values, dates, or categorical data. -
Customizable Operators: The
operatorcolumn stores the comparison operator (e.g., equals, not equals, greater than) used in the filter condition, providing flexibility in how conditions are evaluated. - Security and Access Control: Row-level security policies ensure that only users with the ‘ADMIN’ role from the same company can modify (insert, update, delete) filter conditions, while all users from the same company can view them.
Notes
-
The table includes indexes on
company_idandprocess_step_idcolumns to optimize query performance when filtering by these attributes. -
The
dataset_idcolumn allows for linking filter conditions to specific datasets, which can be useful for more complex filtering scenarios. -
Example usage in TypeScript:
-
The
testFilterConditionandtestFilterfunctions in the codebase are used to evaluate filter conditions against actual data, determining whether a specific data point meets the criteria defined in the filter_conditions table.

