blixify-server 0.3.20 → 0.3.22
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongoWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mongoWrapper.ts"],"names":[],"mappings":"AASA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAGrD,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AA6JD;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,EAAE,GAAG,CAAM;IAClB,UAAU,SAAM;IAChB,MAAM,UAAS;IACf,MAAM,EAAE,cAAc,CAQpB;IACF,GAAG,EAAE,UAAU,CAAC;IAChB,OAAO,SAAM;IACb,KAAK,SAAM;IACX,WAAW,EAAE,GAAG,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAM;IAC7B,KAAK,EAAE,GAAG,CAAC;IAEX,YAAY,QAAS,GAAG,aAEtB;gBAGA,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,EACrD,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACzC,aAAa,CAAC,EAAE,MAAM,EAAE,EACxB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI;IAgB3D,UAAU,SAAU,GAAG,SAIrB;IAEF,aAAa,YACF,GAAG,QACN,QAAQ,GAAG,QAAQ,GAAG,QAAQ,OAC/B,G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,GAAG;IAgR5B,QAAQ,QAAe,GAAG,OAAO,GAAG;;;;;mBAwQlC;IAEF,IAAI,YAgFF;CACH"}
|
|
@@ -858,9 +858,11 @@ class MongoWrapper {
|
|
|
858
858
|
.isValid();
|
|
859
859
|
const isoStartDate = moment_timezone_1.default
|
|
860
860
|
.tz(startDate, "DD/MM/YYYY HH:mm:ss", timezone)
|
|
861
|
+
.utc()
|
|
861
862
|
.toDate();
|
|
862
863
|
const isoEndDate = moment_timezone_1.default
|
|
863
864
|
.tz(endDate, "DD/MM/YYYY HH:mm:ss", timezone)
|
|
865
|
+
.utc()
|
|
864
866
|
.toDate();
|
|
865
867
|
if (!isValidStartDate || !isValidEndDate) {
|
|
866
868
|
res
|
|
@@ -1009,6 +1011,7 @@ class MongoWrapper {
|
|
|
1009
1011
|
return stageKey !== "$skip" && stageKey !== "$limit";
|
|
1010
1012
|
});
|
|
1011
1013
|
countPipeline.push({ $count: "total" });
|
|
1014
|
+
console.log(pipeline);
|
|
1012
1015
|
const [dataList, countResult] = yield Promise.all([
|
|
1013
1016
|
mongoCollection.aggregate(pipeline).toArray(),
|
|
1014
1017
|
mongoCollection.aggregate(countPipeline).toArray(),
|
|
@@ -1135,7 +1138,7 @@ class MongoWrapper {
|
|
|
1135
1138
|
const pipelineList = [];
|
|
1136
1139
|
const addedForeignLookups = new Map();
|
|
1137
1140
|
const addedSpaceReferences = new Set();
|
|
1138
|
-
const { query, sort, cursor, limit, stopLimit, pipeline, uniqueLabel } = req.body;
|
|
1141
|
+
const { query, sort, cursor, limit, stopLimit, pipeline, uniqueLabel, sortBeforeFilter, } = req.body;
|
|
1139
1142
|
try {
|
|
1140
1143
|
if (Array.isArray(pipeline) && pipeline.length > 0) {
|
|
1141
1144
|
pipeline.forEach((link) => {
|
|
@@ -1271,12 +1274,8 @@ class MongoWrapper {
|
|
|
1271
1274
|
}
|
|
1272
1275
|
});
|
|
1273
1276
|
}
|
|
1274
|
-
|
|
1275
|
-
const filter = handleParseQueryFilter(query);
|
|
1276
|
-
pipelineList.push({ $match: filter });
|
|
1277
|
-
}
|
|
1277
|
+
const sortStage = { $sort: {} };
|
|
1278
1278
|
if (sort) {
|
|
1279
|
-
const sortStage = { $sort: {} };
|
|
1280
1279
|
const sortItems = Array.isArray(JSON.parse(JSON.stringify(sort)))
|
|
1281
1280
|
? sort
|
|
1282
1281
|
: [sort];
|
|
@@ -1285,20 +1284,44 @@ class MongoWrapper {
|
|
|
1285
1284
|
sortStage.$sort[sortItem.sortId] = sortItem.type === "asc" ? 1 : -1;
|
|
1286
1285
|
}
|
|
1287
1286
|
});
|
|
1287
|
+
}
|
|
1288
|
+
// INFO: If data is sorted then only filter, group must be before filter as well
|
|
1289
|
+
if (sortBeforeFilter) {
|
|
1288
1290
|
if (Object.keys(sortStage.$sort).length > 0) {
|
|
1289
1291
|
pipelineList.push(sortStage);
|
|
1290
1292
|
}
|
|
1293
|
+
if (uniqueLabel) {
|
|
1294
|
+
pipelineList.push({
|
|
1295
|
+
$group: {
|
|
1296
|
+
_id: `$${uniqueLabel}`,
|
|
1297
|
+
doc: { $first: "$$ROOT" },
|
|
1298
|
+
},
|
|
1299
|
+
});
|
|
1300
|
+
pipelineList.push({
|
|
1301
|
+
$replaceRoot: { newRoot: "$doc" },
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1291
1304
|
}
|
|
1292
|
-
if (
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1305
|
+
if (query && query.length > 0) {
|
|
1306
|
+
const filter = handleParseQueryFilter(query);
|
|
1307
|
+
pipelineList.push({ $match: filter });
|
|
1308
|
+
}
|
|
1309
|
+
// INFO: Default for mongoDB: filter then only sort
|
|
1310
|
+
if (!sortBeforeFilter) {
|
|
1311
|
+
if (Object.keys(sortStage.$sort).length > 0) {
|
|
1312
|
+
pipelineList.push(sortStage);
|
|
1313
|
+
}
|
|
1314
|
+
if (uniqueLabel) {
|
|
1315
|
+
pipelineList.push({
|
|
1316
|
+
$group: {
|
|
1317
|
+
_id: `$${uniqueLabel}`,
|
|
1318
|
+
doc: { $first: "$$ROOT" },
|
|
1319
|
+
},
|
|
1320
|
+
});
|
|
1321
|
+
pipelineList.push({
|
|
1322
|
+
$replaceRoot: { newRoot: "$doc" },
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1302
1325
|
}
|
|
1303
1326
|
if (req.body.attributeIds && req.body.attributeIds.length > 0) {
|
|
1304
1327
|
const projection = { _id: 1 };
|