-
Notifications
You must be signed in to change notification settings - Fork 3
Filtering and filters
Filters are responsible for filtering data received from the loader.
| Available filters | Description |
|---|---|
base |
The base filter that supports complex configuration that allows filter data by different fields with AND, OR, IS, IS NOT, IN, NOT IN conditions. |
| Options | Required | Default | Description |
|---|---|---|---|
| name | false | base | Name of the filter |
| level | false | - | To what level apply filter. See level explanation |
| conditions | true | - | List of conditions. See conditions list and [condition item](#condition item) |
Example:
{
"name": "base"
"level": "crossreference",
"conditions": [
{
"where": "organization",
"condition": "not in",
"value": ["organization-name-1", "organization-name-2"]
}
]
}
List of conditions that will be applied to data item. Conditions propery can be list of objects or list of array, depending on use case. The conditions applied one-by-one, according to it preferable to use most likely conditions first to improve perfomance.
List of arrays need to be declared when OR condition is required.
Example:
"conditions": [
[
{
"where": "state",
"condition": "is",
"value": "MERGED"
}
],
[
{
"where": "type",
"condition": "is",
"value": "issue"
}
]
]
In this example we use OR condition. With this conditions will be selected data where state property is MEREGED OR data type is issue. (If data type is issue the data will be selected whatever the state property is).
List of objects is usefull when AND condition is required.
"conditions": [
{
"where": "state",
"condition": "is",
"value": "MERGED"
},
{
"where": "type",
"condition": "is",
"value": "pullrequest"
}
]
In this example AND condition come in to play. The data will be selected ONLY in case when state is MERGED AND type is pullrequest.
And of cource AND and OR conditions can be combinated.
Example:
"conditions": [
[
{
"where": "state",
"condition": "is",
"value": "MERGED"
},
{
"where": "type",
"condition": "is",
"value": "pullrequest"
}
],
[
{
"where": "type",
"condition": "is",
"value": "issue"
}
]
]
In this example OR and AND conditions is used together. In this case data will be selected if data state is MERGED AND type is pullrequest OR data type is issue.
{
"where": "type",
"condition": "is",
"value": "issue"
}
| Options | Description |
|---|---|
| where | Data object property name |
| condition | One of the condition operators. See condition operators. |
| value | Value that should match data object property (that declared as where) value. Supports boolean values. If property will be declared as boolean, the data object property value will be converted to boolean automatically |
| Operator | Description |
|---|---|
| is | Values exactly match |
| is not | Values don't match |
| in | Data object property exactly one of the value from provided list |
| not in | Data object property don't match any valuee from provided list |
Examples:
- is
{
"where": "type",
"condition": "is",
"value": "issue"
}
Will be true if data object type property is issue.
- is not
{
"where": "type",
"condition": "is not",
"value": "issue"
}
Will be true if data object type property is not issue.
- in
{
"where": "type",
"condition": "in",
"value": ["issue", "pullrequest"]
}
Will be true if data object type property is one of value from the array (issue or pullrequest).
- not in
{
"where": "type",
"condition": "not in",
"value": ["issue", "pullrequest"]
}
Will be true if data object type property is not any of the value from array (issue or pullrequest).
Sometimes we need to filter nested properties from data object, for that application configuration supports level property.
Let's imagine that we have next data object:
{
type: 'issue',
labels: [],
number: 324,
repository: 'repository-name',
organization: 'organization-name',
crossreference: [
{
repository: 'repo-1',
organization: 'org-1',
number: 213
},
{
repository: 'repo-2',
organization: 'org-2',
number: 214
}
]
}
and we want to filter all crossreferences where repository is not repo-1.
To do it we need next configuration:
{
"level": "crossreference",
"conditions": [
{
"where": "repository",
"condition": "is",
"value": "repo-1"
}
]
}
As result we will receive next data object:
{
type: 'issue',
labels: [],
number: 324,
repository: 'repository-name',
organization: 'organization-name',
crossreference: [
{
repository: 'repo-1',
organization: 'org-1',
number: 213
}
]
}
- Create a new
<custom_name>.jsfile under thesrc/filtersfolder. - Create a new class implementing
src/api/filter-interfaceinterface. Note: The name of the file will be used as filter name. - Use your custom filter name and configuration for
loader.config.excludeconfig option. - To support condition mechanism in custom filters use
src/services/filter-conditionservice