semanticdb-core 1.0.37 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,6 +22,10 @@ const tws = (0, date_1.getSupportedTimeWindows)();
|
|
|
22
22
|
*/
|
|
23
23
|
const isDimensionInQuery = (query, dimension, strictMode = true) => {
|
|
24
24
|
const flattenQuery = (0, exports.getFlattenQuery)(query);
|
|
25
|
+
// 最简单的
|
|
26
|
+
if (typeof dimension === 'string' && dimension in flattenQuery) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
25
29
|
if (strictMode) {
|
|
26
30
|
if (typeof dimension === 'string') {
|
|
27
31
|
return dimension in flattenQuery;
|
|
@@ -127,16 +131,43 @@ const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
|
|
|
127
131
|
dimension.level &&
|
|
128
132
|
tws.includes(dimension.level) &&
|
|
129
133
|
logicform.preds) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
// $count by timewindow
|
|
135
|
+
{
|
|
136
|
+
const twPreds = logicform.preds.filter((pred) => pred.operator === '$count' &&
|
|
137
|
+
pred.pred &&
|
|
138
|
+
typeof pred.pred === 'string' &&
|
|
139
|
+
pred.pred.startsWith('$'));
|
|
140
|
+
if (twPreds.length > 0) {
|
|
141
|
+
const minTWGranInLogicform = underscore_1.default.min(twPreds, (i) => tws.indexOf(i.pred.slice(1)));
|
|
142
|
+
// 如果粒度没到,那么就返回false
|
|
143
|
+
if (minTWGranInLogicform && typeof minTWGranInLogicform === 'object') {
|
|
144
|
+
return (tws.indexOf(minTWGranInLogicform.pred.slice(1)) >=
|
|
145
|
+
tws.indexOf(dimension.level));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
{
|
|
150
|
+
const avgPreds = logicform.preds
|
|
151
|
+
.filter((pred) => pred.operator &&
|
|
152
|
+
['$dailyavg', '$monthlyavg', '$yearlyavg', '$weeklyavg'].includes(pred.operator))
|
|
153
|
+
.map((pred) => {
|
|
154
|
+
if (pred.operator === '$dailyavg') {
|
|
155
|
+
return 'day';
|
|
156
|
+
}
|
|
157
|
+
else if (pred.operator === '$monthlyavg') {
|
|
158
|
+
return 'month';
|
|
159
|
+
}
|
|
160
|
+
else if (pred.operator === '$yearlyavg') {
|
|
161
|
+
return 'year';
|
|
162
|
+
}
|
|
163
|
+
else if (pred.operator === '$weeklyavg') {
|
|
164
|
+
return 'week';
|
|
165
|
+
}
|
|
166
|
+
return 'year';
|
|
167
|
+
});
|
|
168
|
+
if (avgPreds.length > 0) {
|
|
169
|
+
const minTWGranInLogicform = underscore_1.default.min(avgPreds, (i) => tws.indexOf(i));
|
|
170
|
+
return tws.indexOf(minTWGranInLogicform) >= tws.indexOf(dimension.level);
|
|
140
171
|
}
|
|
141
172
|
}
|
|
142
173
|
}
|