SYNC: Merge branch 'feature/dblogs'

This commit is contained in:
SPRINX0\prochazka
2025-08-06 12:34:25 +02:00
committed by Diflow
parent 4ed437fd4e
commit ed7605eccd
15 changed files with 241 additions and 153 deletions

View File

@@ -83,3 +83,44 @@ export function selectKeysFromTable(options: {
};
return res;
}
export function createLogCompoudCondition(
fieldFilters: { [field: string]: string[] },
timeColumn: string,
timeFrom: number,
timeTo: number
): Condition {
const conditions: Condition[] = [
{
conditionType: 'binary',
operator: '>=',
left: { exprType: 'column', columnName: timeColumn },
right: { exprType: 'value', value: timeFrom },
},
{
conditionType: 'binary',
operator: '<=',
left: { exprType: 'column', columnName: timeColumn },
right: { exprType: 'value', value: timeTo },
},
];
for (const [key, values] of Object.entries(fieldFilters)) {
if (values.length == 1 && values[0] == null) {
conditions.push({
conditionType: 'isNull',
expr: { exprType: 'column', columnName: key },
});
continue;
}
conditions.push({
conditionType: 'in',
expr: { exprType: 'column', columnName: key },
values,
});
}
return {
conditionType: 'and',
conditions,
};
}