start of view filters
This commit is contained in:
parent
6bd23c0609
commit
a19f370868
|
@ -1,9 +1,45 @@
|
|||
const TOKEN_MAP = {
|
||||
EQUALS: "===",
|
||||
LT: "<",
|
||||
LTE: "<=",
|
||||
MT: ">",
|
||||
MTE: ">=",
|
||||
CONTAINS: "includes()",
|
||||
AND: "&&",
|
||||
OR: "||"
|
||||
}
|
||||
|
||||
function parseFilters(filters) {
|
||||
const expression = filters.map(filter => {
|
||||
if (filter.conjunction) return TOKEN_MAP[filter.conjunction];
|
||||
|
||||
return `doc["${filter.key}"] ${TOKEN_MAP[filter.condition]} "${filter.value}"`
|
||||
})
|
||||
|
||||
return expression.join(" ")
|
||||
}
|
||||
|
||||
function statsViewTemplate({ field, modelId, groupBy }) {
|
||||
return {
|
||||
meta: {
|
||||
field,
|
||||
modelId,
|
||||
groupBy,
|
||||
filter: [
|
||||
{
|
||||
key: "Status",
|
||||
condition: "Equals",
|
||||
value: "VIP",
|
||||
},
|
||||
{
|
||||
conjunction: "AND"
|
||||
},
|
||||
{
|
||||
key: "Status",
|
||||
condition: "Equals",
|
||||
value: "VIP",
|
||||
}
|
||||
],
|
||||
schema: {
|
||||
sum: "number",
|
||||
min: "number",
|
||||
|
|
Loading…
Reference in New Issue