@chevre/domain 22.9.0-alpha.99 → 22.9.0
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/example/src/chevre/offers/checkIncludedInCatalogCount.ts +47 -0
- package/example/src/chevre/offers/createSampleOffers.ts +154 -0
- package/example/src/chevre/offers/projectItemListElement.ts +54 -0
- package/example/src/chevre/{searchOfferCatalogItemAvailability.ts → offers/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts} +17 -5
- package/example/src/chevre/offers/searchByOfferCatalogIdWithSortIndex.ts +44 -0
- package/example/src/chevre/offers/searchOfferCatalogItemAvailability.ts +68 -0
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/chevre/stockHolder/checkIfConflicted.ts +76 -0
- package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +100 -0
- package/example/src/chevre/stockHolder/getSize.ts +97 -0
- package/example/src/chevre/stockHolder/migratePendingReservations.ts +96 -0
- package/example/src/chevre/{playAroundStockHolder.ts → stockHolder/playAroundStockHolder.ts} +119 -132
- package/example/src/chevre/stockHolder/projectPendingReservation.ts +43 -0
- package/example/src/chevre/stockHolder/searchSeats.ts +61 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +5 -5
- package/example/src/chevre/upsertOffersByIdentifier.ts +1 -1
- package/lib/chevre/errorHandler.js +4 -0
- package/lib/chevre/repo/aggregateOffer.d.ts +55 -1
- package/lib/chevre/repo/aggregateOffer.js +320 -13
- package/lib/chevre/repo/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/assetTransaction.js +3 -2
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +10 -9
- package/lib/chevre/repo/mongoose/schemas/note.js +61 -41
- package/lib/chevre/repo/mongoose/schemas/{stockHolderAsReservationPackage.d.ts → pendingReservation.d.ts} +12 -4
- package/lib/chevre/repo/mongoose/schemas/{stockHolderAsReservationPackage.js → pendingReservation.js} +44 -10
- package/lib/chevre/repo/mongoose/schemas/{stockHolder.d.ts → pendingReservationAggregate.d.ts} +3 -7
- package/lib/chevre/repo/mongoose/schemas/{stockHolder.js → pendingReservationAggregate.js} +31 -31
- package/lib/chevre/repo/mongoose/schemas/place.js +13 -27
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +1 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +2 -1
- package/lib/chevre/repo/note.d.ts +2 -2
- package/lib/chevre/repo/note.js +4 -6
- package/lib/chevre/repo/offer/offerInCatalogReadOnly.d.ts +136 -0
- package/lib/chevre/repo/offer/offerInCatalogReadOnly.js +9 -0
- package/lib/chevre/repo/{offer.d.ts → offer/unitPriceInCatalog.d.ts} +23 -101
- package/lib/chevre/repo/{offer.js → offer/unitPriceInCatalog.js} +60 -292
- package/lib/chevre/repo/offerCatalog.d.ts +9 -1
- package/lib/chevre/repo/offerCatalog.js +49 -21
- package/lib/chevre/repo/offerCatalogItem.d.ts +15 -0
- package/lib/chevre/repo/offerCatalogItem.js +25 -0
- package/lib/chevre/repo/pendingReservation.d.ts +103 -0
- package/lib/chevre/repo/pendingReservation.js +677 -0
- package/lib/chevre/repo/place/seat.d.ts +38 -1
- package/lib/chevre/repo/place/seat.js +250 -148
- package/lib/chevre/repo/stockHolder.d.ts +25 -1
- package/lib/chevre/repo/stockHolder.js +69 -19
- package/lib/chevre/repo/stockHolderAbstract.d.ts +15 -0
- package/lib/chevre/repository.d.ts +6 -1
- package/lib/chevre/repository.js +16 -3
- package/lib/chevre/service/aggregation/event/aggregateOffers.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -0
- package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/registerService.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +24 -22
- package/lib/chevre/service/event.js +2 -4
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +1 -1
- package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -2
- package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -1
- package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.d.ts +4 -1
- package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +5 -6
- package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.d.ts +2 -1
- package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.js +36 -15
- package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +1 -1
- package/lib/chevre/service/offer/event/searchOffersByIds.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/validateAcceptedOffers.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +1 -1
- package/lib/chevre/service/offer/onEventChanged.d.ts +2 -0
- package/lib/chevre/service/offer/onEventChanged.js +46 -0
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -1
- package/lib/chevre/service/offer/product.d.ts +1 -1
- package/lib/chevre/service/offer.js +6 -7
- package/lib/chevre/service/project.d.ts +1 -1
- package/lib/chevre/service/task/aggregateOffers.js +4 -4
- package/lib/chevre/service/task/aggregateScreeningEvent.js +4 -4
- package/lib/chevre/service/task/checkResource.js +27 -9
- package/lib/chevre/service/task/importOffersFromCOA.js +3 -3
- package/lib/chevre/service/task/onEventChanged.js +3 -3
- package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.d.ts +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated.js +3 -5
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder.d.ts +1 -1
- package/lib/chevre/service/validation/validateEvent.d.ts +11 -0
- package/lib/chevre/service/validation/validateEvent.js +24 -0
- package/lib/chevre/service/validation/validateOrder.d.ts +4 -0
- package/lib/chevre/service/validation/validateOrder.js +38 -1
- package/package.json +3 -3
- package/example/src/chevre/lockStockHolder.ts +0 -51
- package/example/src/chevre/pullAddOnsFromOffer.ts +0 -26
- package/example/src/chevre/validateOrder.ts +0 -84
- package/lib/chevre/repo/stockHolderAsAggregateReservation.d.ts +0 -40
- package/lib/chevre/repo/stockHolderAsAggregateReservation.js +0 -290
- package/lib/chevre/repo/stockHolderAsReservationPackage.d.ts +0 -35
- package/lib/chevre/repo/stockHolderAsReservationPackage.js +0 -200
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
// tslint:disable-next-line:max-func-body-length
|
|
12
|
+
async function main() {
|
|
13
|
+
const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = aggregateOfferRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
'project.id': { $ne: excludedProject.id }
|
|
18
|
+
// _id: { $eq: 'blyk9q24f' }
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
_id: 1,
|
|
22
|
+
project: 1
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
console.log('docs found');
|
|
26
|
+
|
|
27
|
+
let i = 0;
|
|
28
|
+
await cursor.eachAsync(async (doc) => {
|
|
29
|
+
i += 1;
|
|
30
|
+
const offer: Pick<chevre.factory.aggregateOffer.IAggregateOffer, 'id' | 'project'> = doc.toObject();
|
|
31
|
+
|
|
32
|
+
console.log('count?', offer.project.id, offer.id, i);
|
|
33
|
+
const result = await aggregateOfferRepo.countIncludedInDataCatalog({
|
|
34
|
+
id: { $eq: String(offer.id) }
|
|
35
|
+
});
|
|
36
|
+
console.log('result:', result, offer.project.id, offer.id, i);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
console.log(i, 'docs checked');
|
|
40
|
+
|
|
41
|
+
const resultMax = await aggregateOfferRepo.maxIncludedInDataCatalogCount();
|
|
42
|
+
console.log('resultMax:', resultMax);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
main()
|
|
46
|
+
.then()
|
|
47
|
+
.catch(console.error);
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
const NUM_CREATE_OFFERS = 300;
|
|
8
|
+
const NUM_CREATE_SUB_CATALOGS = 10;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
|
|
15
|
+
const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
|
|
16
|
+
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
17
|
+
const offerCatalogItemRepo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
|
|
18
|
+
|
|
19
|
+
const savingOffers: Omit<chevre.factory.unitPriceOffer.IUnitPriceOffer, 'id'>[] =
|
|
20
|
+
// tslint:disable-next-line:prefer-array-literal
|
|
21
|
+
[...Array(NUM_CREATE_OFFERS)].map<Omit<chevre.factory.unitPriceOffer.IUnitPriceOffer, 'id'>>((__, i) => {
|
|
22
|
+
const identifier = `sampleFreeOffer${i}`;
|
|
23
|
+
const priceSpecification: chevre.factory.unitPriceOffer.IUnitPriceOfferPriceSpecification = {
|
|
24
|
+
typeOf: chevre.factory.priceSpecificationType.UnitPriceSpecification,
|
|
25
|
+
priceCurrency: chevre.factory.priceCurrency.JPY,
|
|
26
|
+
valueAddedTaxIncluded: true,
|
|
27
|
+
price: 0,
|
|
28
|
+
referenceQuantity: {
|
|
29
|
+
value: 1,
|
|
30
|
+
typeOf: 'QuantitativeValue',
|
|
31
|
+
unitCode: chevre.factory.unitCode.C62
|
|
32
|
+
},
|
|
33
|
+
accounting: {
|
|
34
|
+
typeOf: 'Accounting',
|
|
35
|
+
accountsReceivable: 0
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
41
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
42
|
+
identifier,
|
|
43
|
+
description: { en: identifier, ja: identifier },
|
|
44
|
+
alternateName: { ja: identifier },
|
|
45
|
+
name: { en: identifier, ja: identifier },
|
|
46
|
+
availability: chevre.factory.itemAvailability.InStock,
|
|
47
|
+
availableAtOrFrom: [
|
|
48
|
+
{ id: '51qbjcfr72h62m06vtv5kkhgje' }
|
|
49
|
+
],
|
|
50
|
+
itemOffered: { typeOf: chevre.factory.product.ProductType.EventService },
|
|
51
|
+
priceCurrency: chevre.factory.priceCurrency.JPY,
|
|
52
|
+
priceSpecification
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
const saveOfferResult = await aggregateOfferRepo.upsertByIdentifier(savingOffers);
|
|
56
|
+
console.log('saveOfferResult:', saveOfferResult);
|
|
57
|
+
|
|
58
|
+
const offerIds: string[] = (Array.isArray(saveOfferResult?.modifiedOffers)) ? saveOfferResult.modifiedOffers.map(({ id }) => id) : [];
|
|
59
|
+
const catalogIdentifier = 'sampleFreeOffersCatalog';
|
|
60
|
+
const savingOfferCatalog: chevre.factory.offerCatalog.IOfferCatalog = {
|
|
61
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
62
|
+
typeOf: 'OfferCatalog',
|
|
63
|
+
identifier: catalogIdentifier,
|
|
64
|
+
description: { en: catalogIdentifier, ja: catalogIdentifier },
|
|
65
|
+
name: { en: catalogIdentifier, ja: catalogIdentifier },
|
|
66
|
+
itemListElement: offerIds.map((id) => ({ id, typeOf: chevre.factory.offerType.Offer })),
|
|
67
|
+
itemOffered: { typeOf: chevre.factory.product.ProductType.EventService }
|
|
68
|
+
};
|
|
69
|
+
const saveCatalogResult = await offerCatalogRepo.saveByIdentifier(savingOfferCatalog);
|
|
70
|
+
console.log('saveCatalogResult:', saveCatalogResult);
|
|
71
|
+
|
|
72
|
+
const productId = 'sampleFreeEventService';
|
|
73
|
+
const savingProduct: chevre.factory.product.IProduct & {
|
|
74
|
+
offers?: never;
|
|
75
|
+
} = {
|
|
76
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
77
|
+
typeOf: chevre.factory.product.ProductType.EventService,
|
|
78
|
+
name: { en: productId, ja: productId },
|
|
79
|
+
productID: productId,
|
|
80
|
+
hasOfferCatalog: {
|
|
81
|
+
typeOf: 'OfferCatalog',
|
|
82
|
+
itemListElement: [{ id: saveCatalogResult.id }]
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const saveProductResult = await productRepo.upsertManyByProductId([{
|
|
86
|
+
$set: savingProduct
|
|
87
|
+
}]);
|
|
88
|
+
console.log('saveProductResult:', saveProductResult);
|
|
89
|
+
|
|
90
|
+
// 以下サブカタログ
|
|
91
|
+
const offerIds4subCatalog: string[] = (Array.isArray(saveOfferResult?.modifiedOffers))
|
|
92
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
93
|
+
? saveOfferResult.modifiedOffers.slice(0, 100)
|
|
94
|
+
.map(({ id }) => id) :
|
|
95
|
+
[];
|
|
96
|
+
const savingSubOfferCatalogs: chevre.factory.offerCatalog.IOfferCatalog[] =
|
|
97
|
+
// tslint:disable-next-line:prefer-array-literal
|
|
98
|
+
[...Array(NUM_CREATE_SUB_CATALOGS)].map<chevre.factory.offerCatalog.IOfferCatalog>((__, i) => {
|
|
99
|
+
const subCatalogIdentifier = `sampleFreeOffersSubCatalog${i}`;
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
103
|
+
typeOf: 'OfferCatalog',
|
|
104
|
+
identifier: subCatalogIdentifier,
|
|
105
|
+
description: { en: subCatalogIdentifier, ja: subCatalogIdentifier },
|
|
106
|
+
name: { en: subCatalogIdentifier, ja: subCatalogIdentifier },
|
|
107
|
+
itemListElement: offerIds4subCatalog.map((id) => ({ id, typeOf: chevre.factory.offerType.Offer })),
|
|
108
|
+
itemOffered: { typeOf: chevre.factory.product.ProductType.EventService }
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
const saveSubCatalogResult = await offerCatalogItemRepo.upsertManyByIdentifier(savingSubOfferCatalogs.map((savingSubOfferCatalog) => {
|
|
112
|
+
return {
|
|
113
|
+
$set: savingSubOfferCatalog
|
|
114
|
+
};
|
|
115
|
+
}));
|
|
116
|
+
console.log('saveSubCatalogResult:', saveSubCatalogResult);
|
|
117
|
+
|
|
118
|
+
const subCatalogIds: string[] =
|
|
119
|
+
(Array.isArray(saveSubCatalogResult?.modifiedCatalogs)) ? saveSubCatalogResult.modifiedCatalogs.map(({ id }) => id) : [];
|
|
120
|
+
const catalogBySubCatalogIdentifier = 'sampleFreeOffersCatalogBySub';
|
|
121
|
+
const savingOfferCatalogBySubCatalog: chevre.factory.offerCatalog.IOfferCatalog = {
|
|
122
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
123
|
+
typeOf: 'OfferCatalog',
|
|
124
|
+
identifier: catalogBySubCatalogIdentifier,
|
|
125
|
+
description: { en: catalogBySubCatalogIdentifier, ja: catalogBySubCatalogIdentifier },
|
|
126
|
+
name: { en: catalogBySubCatalogIdentifier, ja: catalogBySubCatalogIdentifier },
|
|
127
|
+
itemListElement: subCatalogIds.map((id) => ({ id, typeOf: 'OfferCatalog' })),
|
|
128
|
+
itemOffered: { typeOf: chevre.factory.product.ProductType.EventService }
|
|
129
|
+
};
|
|
130
|
+
const saveCatalogBySubResult = await offerCatalogRepo.saveByIdentifier(savingOfferCatalogBySubCatalog);
|
|
131
|
+
console.log('saveCatalogBySubResult:', saveCatalogBySubResult);
|
|
132
|
+
|
|
133
|
+
const productIdBySubCatalog = 'sampleFreeEventServiceBySub';
|
|
134
|
+
const savingProductBySubCatalog: chevre.factory.product.IProduct & {
|
|
135
|
+
offers?: never;
|
|
136
|
+
} = {
|
|
137
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
138
|
+
typeOf: chevre.factory.product.ProductType.EventService,
|
|
139
|
+
name: { en: productIdBySubCatalog, ja: productIdBySubCatalog },
|
|
140
|
+
productID: productIdBySubCatalog,
|
|
141
|
+
hasOfferCatalog: {
|
|
142
|
+
typeOf: 'OfferCatalog',
|
|
143
|
+
itemListElement: [{ id: saveCatalogBySubResult.id }]
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const saveProductBySubCatalogResult = await productRepo.upsertManyByProductId([{
|
|
147
|
+
$set: savingProductBySubCatalog
|
|
148
|
+
}]);
|
|
149
|
+
console.log('saveProductBySubCatalogResult:', saveProductBySubCatalogResult);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
main()
|
|
153
|
+
.then()
|
|
154
|
+
.catch(console.error);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
const formatter = new Intl.NumberFormat('ja-JP');
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
let startTime: [number, number] = process.hrtime();
|
|
13
|
+
let diff: [number, number] = process.hrtime(startTime);
|
|
14
|
+
let result: any;
|
|
15
|
+
|
|
16
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
17
|
+
|
|
18
|
+
const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
|
|
19
|
+
const offerCatalogItemRepo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
|
|
20
|
+
|
|
21
|
+
// startTime = process.hrtime();
|
|
22
|
+
// result = await offerCatalogRepo.searchItemListElementById({
|
|
23
|
+
// id: 'blpc770py',
|
|
24
|
+
// limit: 100,
|
|
25
|
+
// page: 1
|
|
26
|
+
// });
|
|
27
|
+
// diff = process.hrtime(startTime);
|
|
28
|
+
// console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
29
|
+
// console.log('result:', result);
|
|
30
|
+
|
|
31
|
+
startTime = process.hrtime();
|
|
32
|
+
result = await offerCatalogRepo.sliceItemListElementById({
|
|
33
|
+
id: 'blpc770py',
|
|
34
|
+
limit: 10,
|
|
35
|
+
page: 1
|
|
36
|
+
});
|
|
37
|
+
diff = process.hrtime(startTime);
|
|
38
|
+
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
39
|
+
console.log('result:', result);
|
|
40
|
+
|
|
41
|
+
startTime = process.hrtime();
|
|
42
|
+
result = await offerCatalogItemRepo.sliceItemListElementById({
|
|
43
|
+
id: '65669285c7b871dba60ed72e',
|
|
44
|
+
limit: 10,
|
|
45
|
+
page: 1
|
|
46
|
+
});
|
|
47
|
+
diff = process.hrtime(startTime);
|
|
48
|
+
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
49
|
+
console.log('result:', result);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
main()
|
|
53
|
+
.then()
|
|
54
|
+
.catch(console.error);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
|
|
4
|
-
import { chevre } from '
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const formatter = new Intl.NumberFormat('ja-JP');
|
|
5
7
|
|
|
6
8
|
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
9
|
mongoose.Model.on('index', (...args) => {
|
|
@@ -9,29 +11,39 @@ mongoose.Model.on('index', (...args) => {
|
|
|
9
11
|
});
|
|
10
12
|
|
|
11
13
|
async function main() {
|
|
14
|
+
let startTime: [number, number] = process.hrtime();
|
|
15
|
+
let diff: [number, number] = process.hrtime(startTime);
|
|
16
|
+
let result: any;
|
|
17
|
+
|
|
12
18
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
19
|
|
|
14
20
|
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
21
|
+
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
15
22
|
const offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
|
|
16
23
|
const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
|
|
17
24
|
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
startTime = process.hrtime();
|
|
27
|
+
result = await (await chevre.service.offer.createService()).event.searchOfferAppliesToMovieTicket({
|
|
20
28
|
event: {
|
|
21
|
-
id: '
|
|
29
|
+
id: 'cm8dwc74k'
|
|
22
30
|
},
|
|
23
31
|
limit: 10,
|
|
24
32
|
page: 1,
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
store: { id: '51qbjcfr72h62m06vtv5kkhgje' },
|
|
34
|
+
onlyValid: true,
|
|
35
|
+
options: { useIncludeInDataCatalog: false }
|
|
27
36
|
})({
|
|
28
37
|
event: eventRepo,
|
|
38
|
+
eventSeries: eventSeriesRepo,
|
|
29
39
|
offer: offerRepo,
|
|
30
40
|
offerCatalog: offerCatalogRepo,
|
|
31
41
|
product: productRepo
|
|
32
42
|
});
|
|
43
|
+
diff = process.hrtime(startTime);
|
|
33
44
|
console.log(result);
|
|
34
45
|
console.log(result.length);
|
|
46
|
+
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
main()
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
const offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const result = await offerRepo.searchByOfferCatalogIdWithSortIndex({
|
|
15
|
+
offerCatalog: { id: '65669285c7b871dba60ed72e', isOfferCatalogItem: true },
|
|
16
|
+
// availableAtOrFrom: { id: params.store?.id },
|
|
17
|
+
// unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
18
|
+
excludeAppliesToMovieTicket: false,
|
|
19
|
+
priceSpecification: {
|
|
20
|
+
appliesToMovieTicket: {
|
|
21
|
+
// serviceOutput: {
|
|
22
|
+
// typeOf: {
|
|
23
|
+
// ...(typeof req.query.priceSpecification?.appliesToMovieTicket?.serviceOutput?.typeOf?.$eq === 'string')
|
|
24
|
+
// ? { $eq: req.query.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf.$eq }
|
|
25
|
+
// : undefined
|
|
26
|
+
// }
|
|
27
|
+
// },
|
|
28
|
+
serviceType: {
|
|
29
|
+
$exists: false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
onlyValid: false,
|
|
34
|
+
useIncludeInDataCatalog: true,
|
|
35
|
+
limit: 10,
|
|
36
|
+
page: 1
|
|
37
|
+
});
|
|
38
|
+
console.log('result:', result);
|
|
39
|
+
console.log(result.offers.map(({ name }) => name));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
main()
|
|
43
|
+
.then()
|
|
44
|
+
.catch(console.error);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const formatter = new Intl.NumberFormat('ja-JP');
|
|
7
|
+
|
|
8
|
+
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
9
|
+
mongoose.Model.on('index', (...args) => {
|
|
10
|
+
console.error('******** index event emitted. ********\n', args);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
async function main() {
|
|
14
|
+
let startTime: [number, number] = process.hrtime();
|
|
15
|
+
let diff: [number, number] = process.hrtime(startTime);
|
|
16
|
+
let result: any;
|
|
17
|
+
|
|
18
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
19
|
+
|
|
20
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
21
|
+
const offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
|
|
22
|
+
const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
|
|
23
|
+
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
24
|
+
|
|
25
|
+
// startTime = process.hrtime();
|
|
26
|
+
// result = await (await chevre.service.offer.createService()).event.searchOfferCatalogItemAvailability({
|
|
27
|
+
// event: {
|
|
28
|
+
// id: 'cm8dwc74j'
|
|
29
|
+
// },
|
|
30
|
+
// limit: 10,
|
|
31
|
+
// page: 1,
|
|
32
|
+
// availableAtOrFrom: { id: '51qbjcfr72h62m06vtv5kkhgje' },
|
|
33
|
+
// options: { considerUnacceptedPaymentMethod: true, useIncludeInDataCatalog: true }
|
|
34
|
+
// })({
|
|
35
|
+
// event: eventRepo,
|
|
36
|
+
// offer: offerRepo,
|
|
37
|
+
// offerCatalog: offerCatalogRepo,
|
|
38
|
+
// product: productRepo
|
|
39
|
+
// });
|
|
40
|
+
// diff = process.hrtime(startTime);
|
|
41
|
+
// console.log(result);
|
|
42
|
+
// console.log(result.length);
|
|
43
|
+
// console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
44
|
+
|
|
45
|
+
startTime = process.hrtime();
|
|
46
|
+
result = await (await chevre.service.offer.createService()).event.searchOfferCatalogItemAvailability({
|
|
47
|
+
event: {
|
|
48
|
+
id: 'cm8dwc74j'
|
|
49
|
+
},
|
|
50
|
+
limit: 10,
|
|
51
|
+
page: 1,
|
|
52
|
+
availableAtOrFrom: { id: '51qbjcfr72h62m06vtv5kkhgje' },
|
|
53
|
+
options: { considerUnacceptedPaymentMethod: true, useIncludeInDataCatalog: false }
|
|
54
|
+
})({
|
|
55
|
+
event: eventRepo,
|
|
56
|
+
offer: offerRepo,
|
|
57
|
+
offerCatalog: offerCatalogRepo,
|
|
58
|
+
product: productRepo
|
|
59
|
+
});
|
|
60
|
+
diff = process.hrtime(startTime);
|
|
61
|
+
console.log(result);
|
|
62
|
+
console.log(result.length);
|
|
63
|
+
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
main()
|
|
67
|
+
.then(console.log)
|
|
68
|
+
.catch(console.error);
|
|
@@ -11,7 +11,7 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
await chevre.repository.
|
|
14
|
+
await chevre.repository.Note.createInstance(mongoose.connection);
|
|
15
15
|
console.log('success!');
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
import * as redis from 'redis';
|
|
5
|
+
|
|
6
|
+
import { chevre } from '../../../../lib/index';
|
|
7
|
+
|
|
8
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
10
|
+
|
|
11
|
+
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
12
|
+
socket: {
|
|
13
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
14
|
+
host: <string>process.env.REDIS_HOST
|
|
15
|
+
},
|
|
16
|
+
password: <string>process.env.REDIS_KEY
|
|
17
|
+
})
|
|
18
|
+
.on('error', (err) => {
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.error('createDefaultRedisClient: client onError:', err);
|
|
21
|
+
// reject(err);
|
|
22
|
+
});
|
|
23
|
+
client.connect();
|
|
24
|
+
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
25
|
+
|
|
26
|
+
// tslint:disable-next-line:max-func-body-length
|
|
27
|
+
async function main() {
|
|
28
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
29
|
+
const stockHolderRepo = await chevre.repository.StockHolder.createInstance(
|
|
30
|
+
client,
|
|
31
|
+
mongoose.connection
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const cursor = eventRepo.getCursor(
|
|
35
|
+
{
|
|
36
|
+
'project.id': { $ne: excludedProject.id },
|
|
37
|
+
startDate: {
|
|
38
|
+
$gte: moment()
|
|
39
|
+
.add(-1, 'days')
|
|
40
|
+
.toDate()
|
|
41
|
+
},
|
|
42
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
|
|
43
|
+
// _id: { $eq: 'blyk9q24f' }
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
_id: 1,
|
|
47
|
+
// offers: 1,
|
|
48
|
+
startDate: 1,
|
|
49
|
+
project: 1,
|
|
50
|
+
typeOf: 1
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
console.log('events found');
|
|
54
|
+
|
|
55
|
+
let i = 0;
|
|
56
|
+
await cursor.eachAsync(async (doc) => {
|
|
57
|
+
i += 1;
|
|
58
|
+
const event: Pick<
|
|
59
|
+
chevre.factory.event.screeningEvent.IEvent,
|
|
60
|
+
'id' | 'startDate' | 'project' | 'typeOf'
|
|
61
|
+
> = doc.toObject();
|
|
62
|
+
|
|
63
|
+
console.log(
|
|
64
|
+
'conflicted?', event.project.id, event.typeOf, event.id, event.startDate, i);
|
|
65
|
+
await stockHolderRepo.checkIfConflicted({
|
|
66
|
+
eventId: event.id,
|
|
67
|
+
startDate: event.startDate
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
console.log(i, 'events checked');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
main()
|
|
75
|
+
.then()
|
|
76
|
+
.catch(console.error);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
import * as redis from 'redis';
|
|
5
|
+
|
|
6
|
+
import { chevre } from '../../../../lib/index';
|
|
7
|
+
|
|
8
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
|
|
10
|
+
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
11
|
+
socket: {
|
|
12
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
13
|
+
host: <string>process.env.REDIS_HOST
|
|
14
|
+
},
|
|
15
|
+
password: <string>process.env.REDIS_KEY
|
|
16
|
+
})
|
|
17
|
+
.on('error', (err) => {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.error('createDefaultRedisClient: client onError:', err);
|
|
20
|
+
// reject(err);
|
|
21
|
+
});
|
|
22
|
+
client.connect();
|
|
23
|
+
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
24
|
+
|
|
25
|
+
// tslint:disable-next-line:max-func-body-length
|
|
26
|
+
async function main() {
|
|
27
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
28
|
+
const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
|
|
29
|
+
const stockHolderRepo = await chevre.repository.StockHolder.createInstance(
|
|
30
|
+
client,
|
|
31
|
+
mongoose.connection
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const setting = await settingRepo.findOne(
|
|
35
|
+
{ project: { id: { $eq: '*' } } },
|
|
36
|
+
['useMongoAsStockHolderProjects']
|
|
37
|
+
);
|
|
38
|
+
const useMongoAsStockHolderProjects =
|
|
39
|
+
(Array.isArray(setting?.useMongoAsStockHolderProjects)) ? setting?.useMongoAsStockHolderProjects : [];
|
|
40
|
+
|
|
41
|
+
if (useMongoAsStockHolderProjects.length === 0) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const cursor = eventRepo.getCursor(
|
|
46
|
+
{
|
|
47
|
+
'project.id': {
|
|
48
|
+
$eq: 'toei-production',
|
|
49
|
+
$in: useMongoAsStockHolderProjects
|
|
50
|
+
},
|
|
51
|
+
startDate: {
|
|
52
|
+
$gte: moment()
|
|
53
|
+
.add(0, 'days')
|
|
54
|
+
.toDate()
|
|
55
|
+
},
|
|
56
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
|
|
57
|
+
// _id: { $eq: 'blyk9q24f' }
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
_id: 1,
|
|
61
|
+
// offers: 1,
|
|
62
|
+
startDate: 1,
|
|
63
|
+
project: 1,
|
|
64
|
+
typeOf: 1
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
console.log('events found');
|
|
68
|
+
|
|
69
|
+
let i = 0;
|
|
70
|
+
let redisKeyCount = 0;
|
|
71
|
+
const eventsWithRedis: string[] = [];
|
|
72
|
+
await cursor.eachAsync(async (doc) => {
|
|
73
|
+
i += 1;
|
|
74
|
+
const event: Pick<
|
|
75
|
+
chevre.factory.event.screeningEvent.IEvent,
|
|
76
|
+
'id' | 'startDate' | 'project' | 'typeOf'
|
|
77
|
+
> = doc.toObject();
|
|
78
|
+
|
|
79
|
+
console.log('redisKeyExists?', event.project.id, event.typeOf, event.id, event.startDate, i);
|
|
80
|
+
const redisKeyExists = await stockHolderRepo.redisKeyExists({
|
|
81
|
+
eventId: event.id,
|
|
82
|
+
startDate: event.startDate
|
|
83
|
+
});
|
|
84
|
+
console.log('redisKeyExists:', redisKeyExists, event.project.id, event.typeOf, event.id, event.startDate, i);
|
|
85
|
+
|
|
86
|
+
if (redisKeyExists) {
|
|
87
|
+
redisKeyCount += 1;
|
|
88
|
+
eventsWithRedis.push(event.id);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
console.log(i, 'events checked');
|
|
93
|
+
console.log(redisKeyCount, 'redisKeys found');
|
|
94
|
+
console.log('useMongoAsStockHolderProjects:', useMongoAsStockHolderProjects);
|
|
95
|
+
// console.log('eventsWithRedis:', eventsWithRedis);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
main()
|
|
99
|
+
.then()
|
|
100
|
+
.catch(console.error);
|