MCPcopy Create free account
hub / github.com/chartbrew/chartbrew / normalizeFilter

Function normalizeFilter

server/modules/chartRuntimeFilters.js:63–94  ·  view source on GitHub ↗
(filter = {})

Source from the content-addressed store, hash-verified

61}
62
63function normalizeFilter(filter = {}) {
64 if (!filter) return null;
65
66 const filterType = filter.type || "field";
67
68 if (filter.type === "date" && filter.startDate && filter.endDate) {
69 return {
70 type: "date",
71 startDate: filter.startDate,
72 endDate: filter.endDate,
73 origin: filter.origin || "dashboard",
74 scope: filter.scope || "chart",
75 cdcId: filter.cdcId ?? null,
76 clientOnly: Boolean(filter.clientOnly),
77 };
78 }
79
80 if (!filter.field) return null;
81
82 return {
83 type: filterType,
84 field: filter.field,
85 operator: filter.operator,
86 value: normalizeValue(filter.value),
87 exposed: Boolean(filter.exposed),
88 origin: filter.origin || (filter.cdcId ? "chart" : "dashboard"),
89 scope: filter.scope || (filter.cdcId ? "cdc" : "chart"),
90 cdcId: filter.cdcId ?? null,
91 clientOnly: Boolean(filter.clientOnly) || CLIENT_ONLY_FILTER_TYPES.has(filterType),
92 forceSourceRefresh: Boolean(filter.forceSourceRefresh),
93 };
94}
95
96function getFilterKey(filter = {}) {
97 return JSON.stringify({

Callers 1

dedupeFiltersFunction · 0.85

Calls 1

normalizeValueFunction · 0.70

Tested by

no test coverage detected