semanticdb-core 1.0.38 → 1.0.40

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.
@@ -131,16 +131,56 @@ const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
131
131
  dimension.level &&
132
132
  tws.includes(dimension.level) &&
133
133
  logicform.preds) {
134
- const twPreds = logicform.preds.filter((pred) => pred.operator === '$count' &&
135
- pred.pred &&
136
- typeof pred.pred === 'string' &&
137
- pred.pred.startsWith('$'));
138
- if (twPreds.length > 0) {
139
- const minTWGranInLogicform = underscore_1.default.min(twPreds, (i) => tws.indexOf(i.pred.slice(1)));
140
- // 如果粒度没到,那么就返回false
141
- if (minTWGranInLogicform && typeof minTWGranInLogicform === 'object') {
142
- return (tws.indexOf(minTWGranInLogicform.pred.slice(1)) >=
143
- tws.indexOf(dimension.level));
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
+ // dailyavg', '$monthlyavg', '$yearlyavg', '$weeklyavg, to be deprecated
150
+ {
151
+ const avgPreds = logicform.preds
152
+ .filter((pred) => pred.operator &&
153
+ ['$dailyavg', '$monthlyavg', '$yearlyavg', '$weeklyavg'].includes(pred.operator))
154
+ .map((pred) => {
155
+ if (pred.operator === '$dailyavg') {
156
+ return 'day';
157
+ }
158
+ else if (pred.operator === '$monthlyavg') {
159
+ return 'month';
160
+ }
161
+ else if (pred.operator === '$yearlyavg') {
162
+ return 'year';
163
+ }
164
+ else if (pred.operator === '$weeklyavg') {
165
+ return 'week';
166
+ }
167
+ return 'year';
168
+ });
169
+ if (avgPreds.length > 0) {
170
+ const minTWGranInLogicform = underscore_1.default.min(avgPreds, (i) => tws.indexOf(i));
171
+ return tws.indexOf(minTWGranInLogicform) >= tws.indexOf(dimension.level);
172
+ }
173
+ }
174
+ // by timewindow:这个可能是未来唯一的表达方式
175
+ {
176
+ const twPreds = logicform.preds.filter((pred) => pred.by && typeof pred.by === 'string' && pred.by.startsWith('$'));
177
+ if (twPreds.length > 0) {
178
+ const minTWGranInLogicform = underscore_1.default.min(twPreds, (i) => tws.indexOf(i.by.slice(1)));
179
+ // 如果粒度没到,那么就返回false
180
+ if (minTWGranInLogicform && typeof minTWGranInLogicform === 'object') {
181
+ return (tws.indexOf(minTWGranInLogicform.by.slice(1)) >=
182
+ tws.indexOf(dimension.level));
183
+ }
144
184
  }
145
185
  }
146
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semanticdb-core",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [