@7365admin1/core 3.64.1 → 3.64.2
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.
- package/CHANGELOG.md +20 -0
- package/dist/index.js +14 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/customer-sites-one-row-per-site.test.mjs +107 -0
package/dist/index.mjs
CHANGED
|
@@ -13478,7 +13478,6 @@ function useCustomerSiteRepo() {
|
|
|
13478
13478
|
cacheOptions.siteScope = scoped.length ? [...scoped].sort().join(",") : "no-site";
|
|
13479
13479
|
}
|
|
13480
13480
|
if (search) {
|
|
13481
|
-
query2.$or = [{ name: { $regex: search, $options: "i" } }];
|
|
13482
13481
|
cacheOptions.search = search;
|
|
13483
13482
|
}
|
|
13484
13483
|
const cacheKey = makeCacheKey10(namespace_collection2, cacheOptions);
|
|
@@ -13491,8 +13490,20 @@ function useCustomerSiteRepo() {
|
|
|
13491
13490
|
const distinctPipeline = [
|
|
13492
13491
|
{ $match: query2 },
|
|
13493
13492
|
{ $sort: sort },
|
|
13494
|
-
{ $group: { _id:
|
|
13493
|
+
{ $group: { _id: "$site", doc: { $first: "$$ROOT" } } },
|
|
13495
13494
|
{ $replaceRoot: { newRoot: "$doc" } },
|
|
13495
|
+
{
|
|
13496
|
+
$lookup: {
|
|
13497
|
+
from: "sites",
|
|
13498
|
+
localField: "site",
|
|
13499
|
+
foreignField: "_id",
|
|
13500
|
+
as: "_liveSite"
|
|
13501
|
+
}
|
|
13502
|
+
},
|
|
13503
|
+
{ $unwind: { path: "$_liveSite", preserveNullAndEmptyArrays: true } },
|
|
13504
|
+
{ $set: { name: { $ifNull: ["$_liveSite.name", "$name"] } } },
|
|
13505
|
+
{ $unset: "_liveSite" },
|
|
13506
|
+
...search ? [{ $match: { name: { $regex: search, $options: "i" } } }] : [],
|
|
13496
13507
|
{ $sort: sort }
|
|
13497
13508
|
];
|
|
13498
13509
|
const items = await collection.aggregate(
|
|
@@ -13503,14 +13514,7 @@ function useCustomerSiteRepo() {
|
|
|
13503
13514
|
],
|
|
13504
13515
|
{ session }
|
|
13505
13516
|
).toArray();
|
|
13506
|
-
const countResult = await collection.aggregate(
|
|
13507
|
-
[
|
|
13508
|
-
{ $match: query2 },
|
|
13509
|
-
{ $group: { _id: { name: "$name", site: "$site" } } },
|
|
13510
|
-
{ $count: "total" }
|
|
13511
|
-
],
|
|
13512
|
-
{ session }
|
|
13513
|
-
).toArray();
|
|
13517
|
+
const countResult = await collection.aggregate([...distinctPipeline, { $count: "total" }], { session }).toArray();
|
|
13514
13518
|
const length = countResult[0]?.total ?? 0;
|
|
13515
13519
|
const data = paginate10(items, page, limit, length);
|
|
13516
13520
|
setCache(cacheKey, data, 15 * 60).then(() => {
|