2454 update filter definition to work with new backend (#2482)

* wip

* filters are working

* updated functions

* remove comment

* improve readability
This commit is contained in:
bosiraphael
2023-11-13 18:05:49 +01:00
committed by GitHub
parent 3de2fc72dc
commit 230459b23c
9 changed files with 133 additions and 50 deletions

View File

@ -45,6 +45,40 @@ export const turnFiltersIntoWhereClauseV2 = (
`Unknown operand ${filter.operand} for ${filter.definition.type} filter`,
);
}
case 'NUMBER':
switch (filter.operand) {
case ViewFilterOperand.GreaterThan:
whereClause[correspondingField.name] = {
gte: parseFloat(filter.value),
};
return;
case ViewFilterOperand.LessThan:
whereClause[correspondingField.name] = {
lte: parseFloat(filter.value),
};
return;
default:
throw new Error(
`Unknown operand ${filter.operand} for ${filter.definition.type} filter`,
);
}
case 'DATE':
switch (filter.operand) {
case ViewFilterOperand.GreaterThan:
whereClause[correspondingField.name] = {
gte: filter.value,
};
return;
case ViewFilterOperand.LessThan:
whereClause[correspondingField.name] = {
lte: filter.value,
};
return;
default:
throw new Error(
`Unknown operand ${filter.operand} for ${filter.definition.type} filter`,
);
}
default:
throw new Error('Unknown filter type');
}