@chevre/domain 21.9.0-alpha.6 → 21.9.0-alpha.8
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.
|
@@ -27,6 +27,15 @@ async function main() {
|
|
|
27
27
|
console.log(catalogs[0]?.id, typeof catalogs[0]?.id);
|
|
28
28
|
console.log('catalogs found', catalogs.map((catalog) => `${catalog.id} ${catalog.identifier} ${catalog.numberOfItems} ${catalog.itemListElementTypeOf}`));
|
|
29
29
|
console.log(catalogs.length);
|
|
30
|
+
|
|
31
|
+
const numCatalogs = await catalogItemRepo.count(
|
|
32
|
+
{
|
|
33
|
+
project: { id: { $eq: PROJECT_ID } },
|
|
34
|
+
itemListElement: { typeOf: { $eq: 'Offer' } }
|
|
35
|
+
// id: { $in: ['xxx'] }
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
console.log('numCatalogs:', numCatalogs);
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
main()
|
|
@@ -19,6 +19,7 @@ export declare class MongoRepository {
|
|
|
19
19
|
id: string;
|
|
20
20
|
dateSynced: Date;
|
|
21
21
|
}): Promise<void>;
|
|
22
|
+
count(params: Omit<factory.offerCatalog.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
22
23
|
search(params: factory.offerCatalog.ISearchConditions): Promise<IAggregatedOfferCatalog[]>;
|
|
23
24
|
findItemListElementById(params: {
|
|
24
25
|
id: string;
|
|
@@ -130,6 +130,22 @@ class MongoRepository {
|
|
|
130
130
|
.exec();
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
+
count(params) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
136
|
+
const matchStages = conditions.map((condition) => {
|
|
137
|
+
return { $match: condition };
|
|
138
|
+
});
|
|
139
|
+
const result = yield this.offerCatalogItemModel.aggregate([
|
|
140
|
+
...matchStages,
|
|
141
|
+
{
|
|
142
|
+
$count: 'numItems'
|
|
143
|
+
}
|
|
144
|
+
])
|
|
145
|
+
.exec();
|
|
146
|
+
return (result.length > 0) ? result[0].numItems : 0;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
133
149
|
search(params) {
|
|
134
150
|
var _a;
|
|
135
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -19,24 +19,18 @@ function syncOfferCatalog(params) {
|
|
|
19
19
|
// if (params.ids.length !== 1) {
|
|
20
20
|
// throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
21
21
|
// }
|
|
22
|
-
var _a
|
|
22
|
+
var _a;
|
|
23
23
|
if (params.isDeleted) {
|
|
24
24
|
for (const offerCatalogId of params.ids) {
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
break;
|
|
37
|
-
default:
|
|
38
|
-
// no op
|
|
39
|
-
}
|
|
25
|
+
// 検索しても存在しない
|
|
26
|
+
// const offerCatalogs = await repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
|
|
27
|
+
// カタログを含む全集計オファーからカタログを除外
|
|
28
|
+
yield repos.aggregateOffer.pullIncludedInDataCatalog({
|
|
29
|
+
project: { id: params.project.id },
|
|
30
|
+
$pull: {
|
|
31
|
+
includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
|
|
32
|
+
}
|
|
33
|
+
});
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
else {
|
|
@@ -48,7 +42,7 @@ function syncOfferCatalog(params) {
|
|
|
48
42
|
else {
|
|
49
43
|
offerCatalogs = yield repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
|
|
50
44
|
}
|
|
51
|
-
const itemListElementTypeOf = (
|
|
45
|
+
const itemListElementTypeOf = (_a = offerCatalogs.shift()) === null || _a === void 0 ? void 0 : _a.itemListElementTypeOf;
|
|
52
46
|
switch (itemListElementTypeOf) {
|
|
53
47
|
case factory.offerType.Offer:
|
|
54
48
|
// 集計オファーIDリストを検索
|
package/package.json
CHANGED