@chevre/domain 21.13.0 → 21.15.0-alpha.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.
Files changed (53) hide show
  1. package/example/src/chevre/aggregateAllEvents.ts +2 -2
  2. package/example/src/chevre/aggregateAllEvents2.ts +1 -1
  3. package/example/src/chevre/aggregateEventReservation.ts +11 -11
  4. package/example/src/chevre/aggregateSellerPaymentAccepted.ts +1 -1
  5. package/example/src/chevre/aggregation/aggregateSystem.ts +20 -20
  6. package/example/src/chevre/attendIfNotAttended.ts +1 -1
  7. package/example/src/chevre/checkEventDuration.ts +59 -0
  8. package/example/src/chevre/cleanAccountingReports.ts +1 -1
  9. package/example/src/chevre/cleanActions.ts +1 -1
  10. package/example/src/chevre/deleteRunsAtPassedCertainPeriod.ts +1 -1
  11. package/example/src/chevre/deleteTasksByName.ts +1 -1
  12. package/example/src/chevre/findItemListElementByCatalogId.ts +1 -1
  13. package/example/src/chevre/giveUpStartDatePassedCertainPeriod.ts +1 -1
  14. package/example/src/chevre/importCategoryCodesFromCOA.ts +5 -4
  15. package/example/src/chevre/importOffersFromCOA.ts +7 -6
  16. package/example/src/chevre/lockStockHolder.ts +1 -1
  17. package/example/src/chevre/migrateCategoryCodeAdditionalProperties.ts +2 -2
  18. package/example/src/chevre/migrateIAMMemberMemberOf.ts +1 -1
  19. package/example/src/chevre/migrateMovieAvailabilityStarts.ts +1 -1
  20. package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +3 -3
  21. package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +1 -1
  22. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +1 -1
  23. package/example/src/chevre/optimizeCatalogs.ts +1 -1
  24. package/example/src/chevre/place/adminHasPOS.ts +1 -1
  25. package/example/src/chevre/pullAddOnsFromOffer.ts +1 -1
  26. package/example/src/chevre/pushIncludedInDataCatalog.ts +1 -1
  27. package/example/src/chevre/searchActions.ts +1 -1
  28. package/example/src/chevre/searchAggregateOffers.ts +1 -1
  29. package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +5 -5
  30. package/example/src/chevre/searchEventIds.ts +1 -1
  31. package/example/src/chevre/searchEventSeats.ts +1 -1
  32. package/example/src/chevre/searchOfferCatalogItemAvailability.ts +5 -5
  33. package/example/src/chevre/searchOfferCatalogItems.ts +5 -5
  34. package/example/src/chevre/searchOffers.ts +2 -2
  35. package/example/src/chevre/searchPermissions.ts +3 -3
  36. package/example/src/chevre/searchProductOffers.ts +1 -1
  37. package/example/src/chevre/searchSellers.ts +2 -2
  38. package/lib/chevre/factory/event.d.ts +1 -1
  39. package/lib/chevre/factory/event.js +2 -8
  40. package/lib/chevre/repo/event.d.ts +5 -20
  41. package/lib/chevre/repo/event.js +47 -56
  42. package/lib/chevre/repo/priceSpecification.d.ts +0 -5
  43. package/lib/chevre/repo/priceSpecification.js +0 -9
  44. package/lib/chevre/repo/stockHolder.d.ts +0 -11
  45. package/lib/chevre/repo/stockHolder.js +11 -284
  46. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +28 -13
  47. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +6 -8
  48. package/lib/chevre/service/offer.js +25 -7
  49. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +3 -1
  50. package/lib/chevre/service/transaction/returnOrder.js +5 -3
  51. package/package.json +1 -1
  52. package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +0 -21
  53. package/example/src/chevre/place/migrateHasPOS.ts +0 -76
@@ -13,7 +13,7 @@ exports.StockHolderRepository = void 0;
13
13
  const createDebug = require("debug");
14
14
  const moment = require("moment");
15
15
  const factory = require("../factory");
16
- const settings_1 = require("../settings");
16
+ // import { USE_NEW_EVENT_AVAILABILITY_KEY_FROM } from '../settings';
17
17
  const debug = createDebug('chevre-domain:repo:stockHolder');
18
18
  /**
19
19
  * イベントストックホルダーリポジトリ
@@ -38,41 +38,18 @@ class StockHolderRepository {
38
38
  }
39
39
  }
40
40
  }
41
- // private static offer2subReservation(params: IOffer, hasTicketedSeat: boolean): ISubReservation {
42
- // if (hasTicketedSeat) {
43
- // return {
44
- // identifier: `${params.seatSection}:${params.seatNumber}`,
45
- // reservedTicket: {
46
- // ticketedSeat: {
47
- // seatSection: params.seatSection,
48
- // seatNumber: params.seatNumber
49
- // }
50
- // }
51
- // };
52
- // } else {
53
- // const serviceOutputId = params.itemOffered?.serviceOutput?.id;
54
- // if (typeof serviceOutputId === 'string') {
55
- // return {
56
- // id: serviceOutputId,
57
- // identifier: serviceOutputId
58
- // };
59
- // } else {
60
- // throw new factory.errors.ServiceUnavailable('offer2subReservation requires itemOffered.serviceOutput.id');
61
- // }
62
- // }
63
- // }
64
41
  static createKey(params) {
65
42
  if (!(params.startDate instanceof Date)) {
66
43
  throw new factory.errors.Argument('startDate', 'must be Date');
67
44
  }
68
- const useNewKey = moment(params.startDate)
69
- .isSameOrAfter(settings_1.USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
70
- if (useNewKey) {
71
- return `${StockHolderRepository.KEY_PREFIX_NEW}:${params.eventId}`;
72
- }
73
- else {
74
- return `${StockHolderRepository.KEY_PREFIX}:${params.eventId}`;
75
- }
45
+ return `${StockHolderRepository.KEY_PREFIX_NEW}:${params.eventId}`;
46
+ // const useNewKey: boolean = moment(params.startDate)
47
+ // .isSameOrAfter(USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
48
+ // if (useNewKey) {
49
+ // return `${StockHolderRepository.KEY_PREFIX_NEW}:${params.eventId}`;
50
+ // } else {
51
+ // return `${StockHolderRepository.KEY_PREFIX}:${params.eventId}`;
52
+ // }
76
53
  }
77
54
  /**
78
55
  * 新リポジトリを使用するかどうか
@@ -125,7 +102,7 @@ class StockHolderRepository {
125
102
  hasTicketedSeat: lockKey.hasTicketedSeat
126
103
  });
127
104
  const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
128
- yield this.checkIfConflicted({ key, eventId: lockKey.eventId, useMongoose });
105
+ // await this.checkIfConflicted({ key, eventId: lockKey.eventId, useMongoose });
129
106
  if (useMongoose) {
130
107
  throw new factory.errors.NotImplemented('new stock holder repository not implemented');
131
108
  }
@@ -182,7 +159,7 @@ class StockHolderRepository {
182
159
  hasTicketedSeat: params.hasTicketedSeat
183
160
  });
184
161
  const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
185
- yield this.checkIfConflicted({ key, eventId: params.eventId, useMongoose });
162
+ // await this.checkIfConflicted({ key, eventId: params.eventId, useMongoose });
186
163
  if (useMongoose) {
187
164
  throw new factory.errors.NotImplemented('new stock holder repository not implemented');
188
165
  }
@@ -194,23 +171,6 @@ class StockHolderRepository {
194
171
  }
195
172
  });
196
173
  }
197
- /**
198
- * 空席でない座席を検索する
199
- */
200
- // public async findUnavailableOffersByEventId(params: { eventId: string; startDate: Date }): Promise<IOffer[]> {
201
- // const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
202
- // const reply = await this.redisClient.hGetAll(key);
203
- // let offers: IOffer[] = [];
204
- // if (reply !== null) {
205
- // offers = Object.keys(reply)
206
- // .map((field) => {
207
- // const seatSection = field.split(':')[0];
208
- // const seatNumber = field.split(':')[1];
209
- // return { seatSection, seatNumber };
210
- // });
211
- // }
212
- // return offers;
213
- // }
214
174
  /**
215
175
  * 空席でない座席をカウントする
216
176
  */
@@ -277,239 +237,6 @@ class StockHolderRepository {
277
237
  }
278
238
  });
279
239
  }
280
- // public async migrateKey(params: {
281
- // key: string;
282
- // eventId: string;
283
- // }): Promise<void> {
284
- // // 旧キーと新キーの両方存在検証(念のため)
285
- // const oldKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2020-01-01T00:00:00Z') });
286
- // const newKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2030-01-01T00:00:00Z') });
287
- // if (params.key !== oldKey) {
288
- // // newの場合oldが存在するはずがない
289
- // const existingOldKeyCount = await this.redisClient.exists(oldKey);
290
- // debug('existingOldKeyCount:', existingOldKeyCount);
291
- // if (existingOldKeyCount > 0) {
292
- // await this.redisClient.del(oldKey);
293
- // }
294
- // }
295
- // if (params.key !== newKey) {
296
- // // oldの場合newが存在するはずがない
297
- // const existingNewKeyCount = await this.redisClient.exists(newKey);
298
- // debug('existingNewKeyCount:', existingNewKeyCount);
299
- // if (existingNewKeyCount > 0) {
300
- // await this.redisClient.del(newKey);
301
- // }
302
- // }
303
- // }
304
- /**
305
- * 汎用的な検索(mongooseのみ対応)
306
- */
307
- // tslint:disable-next-line:max-func-body-length
308
- // public async search(params: {
309
- // limit?: number;
310
- // page?: number;
311
- // sort?: { 'reservationFor.startDate': factory.sortType };
312
- // project?: { id?: { $eq?: string } };
313
- // reservationFor?: { id?: { $eq?: string } };
314
- // reservationNumber?: { $eq?: string };
315
- // id?: { $eq?: string };
316
- // identifier?: { $eq?: string };
317
- // reservedTicket?: {
318
- // ticketedSeat?: {
319
- // seatNumber?: { $eq?: string };
320
- // seatSection?: { $eq?: string };
321
- // };
322
- // };
323
- // }): Promise<ISearchResult[]> {
324
- // const matchStages: IMatchStage[] = [];
325
- // const projectIdEq = params.project?.id?.$eq;
326
- // if (typeof projectIdEq === 'string') {
327
- // matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
328
- // }
329
- // const reservationForIdEq = params.reservationFor?.id?.$eq;
330
- // if (typeof reservationForIdEq === 'string') {
331
- // matchStages.push({ $match: { 'reservationFor.id': { $eq: reservationForIdEq } } });
332
- // }
333
- // const reservationNumberEq = params.reservationNumber?.$eq;
334
- // if (typeof reservationNumberEq === 'string') {
335
- // matchStages.push({ $match: { 'reservations.reservationNumber': { $exists: true, $eq: reservationNumberEq } } });
336
- // }
337
- // const identifierEq = params.identifier?.$eq;
338
- // if (typeof identifierEq === 'string') {
339
- // matchStages.push({ $match: { 'reservations.subReservation.identifier': { $exists: true, $eq: identifierEq } } });
340
- // }
341
- // const idEq = params.id?.$eq;
342
- // if (typeof idEq === 'string') {
343
- // matchStages.push({
344
- // $match: { 'reservations.subReservation.id': { $exists: true, $eq: idEq } }
345
- // });
346
- // }
347
- // const seatNumberEq = params.reservedTicket?.ticketedSeat?.seatNumber?.$eq;
348
- // if (typeof seatNumberEq === 'string') {
349
- // matchStages.push({
350
- // $match: {
351
- // 'reservations.subReservation.reservedTicket.ticketedSeat.seatNumber': {
352
- // $exists: true,
353
- // $eq: seatNumberEq
354
- // }
355
- // }
356
- // });
357
- // }
358
- // const seatSectionEq = params.reservedTicket?.ticketedSeat?.seatSection?.$eq;
359
- // if (typeof seatSectionEq === 'string') {
360
- // matchStages.push({
361
- // $match: {
362
- // 'reservations.subReservation.reservedTicket.ticketedSeat.seatSection': {
363
- // $exists: true,
364
- // $eq: seatSectionEq
365
- // }
366
- // }
367
- // });
368
- // }
369
- // const aggregate = this.holdReservationModel.aggregate([
370
- // ...(typeof params.sort?.['reservationFor.startDate'] === 'number')
371
- // ? [{ $sort: { 'reservationFor.startDate': params.sort['reservationFor.startDate'] } }]
372
- // : [],
373
- // {
374
- // $unwind: {
375
- // path: '$reservations',
376
- // includeArrayIndex: 'reservationPackageIndex'
377
- // }
378
- // },
379
- // {
380
- // $unwind: {
381
- // path: '$reservations.subReservation',
382
- // includeArrayIndex: 'subReservationIndex'
383
- // }
384
- // },
385
- // ...matchStages,
386
- // {
387
- // $project: {
388
- // _id: 0,
389
- // id: '$reservations.subReservation.id',
390
- // identifier: '$reservations.subReservation.identifier',
391
- // reservationFor: {
392
- // id: '$reservationFor.id',
393
- // startDate: '$reservationFor.startDate',
394
- // aggregateReservation: {
395
- // reservationCount: '$reservationCount'
396
- // }
397
- // },
398
- // reservationNumber: '$reservations.reservationNumber',
399
- // reservedTicket: '$reservations.subReservation.reservedTicket',
400
- // objectSize: { $bsonSize: '$$ROOT' },
401
- // reservationPackageIndex: '$reservationPackageIndex',
402
- // subReservationIndex: '$subReservationIndex'
403
- // }
404
- // }
405
- // ]);
406
- // if (typeof params.limit === 'number' && params.limit > 0) {
407
- // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
408
- // aggregate.limit(params.limit * page)
409
- // .skip(params.limit * (page - 1));
410
- // }
411
- // return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
412
- // .exec();
413
- // }
414
- /**
415
- * 汎用的な集計(mongooseのみ対応)
416
- */
417
- // public async aggregateByReservationFor(params: {
418
- // limit?: number;
419
- // page?: number;
420
- // project?: { id?: { $eq?: string } };
421
- // reservationFor?: { id?: { $eq?: string } };
422
- // }): Promise<{
423
- // typeOf: 'AggregateReservation';
424
- // reservationCount: number;
425
- // reservationFor: {
426
- // id: string;
427
- // startDate: Date;
428
- // };
429
- // reservationPackageCount: number;
430
- // objectSize: number;
431
- // }[]> {
432
- // const matchStages: IMatchStage[] = [];
433
- // const projectIdEq = params.project?.id?.$eq;
434
- // if (typeof projectIdEq === 'string') {
435
- // matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
436
- // }
437
- // const reservationForIdEq = params.reservationFor?.id?.$eq;
438
- // if (typeof reservationForIdEq === 'string') {
439
- // matchStages.push({ $match: { 'reservationFor.id': { $eq: reservationForIdEq } } });
440
- // }
441
- // const aggregate = this.holdReservationModel.aggregate([
442
- // ...matchStages,
443
- // {
444
- // $project: {
445
- // _id: 0,
446
- // typeOf: '$typeOf',
447
- // reservationCount: '$reservationCount',
448
- // reservationFor: '$reservationFor',
449
- // reservationPackageCount: { $size: '$reservations' },
450
- // objectSize: { $bsonSize: '$$ROOT' }
451
- // }
452
- // }
453
- // ]);
454
- // if (typeof params.limit === 'number' && params.limit > 0) {
455
- // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
456
- // aggregate.limit(params.limit * page)
457
- // .skip(params.limit * (page - 1));
458
- // }
459
- // return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
460
- // .exec();
461
- // }
462
- checkIfConflicted(params) {
463
- return __awaiter(this, void 0, void 0, function* () {
464
- // 旧キーと新キーの両方存在検証(念のため)
465
- const oldKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2020-01-01T00:00:00Z') });
466
- const newKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2030-01-01T00:00:00Z') });
467
- if (params.useMongoose) {
468
- throw new factory.errors.NotImplemented('new stock holder repository not implemented');
469
- // newもoldも存在するはずがない
470
- // newの場合oldが存在するはずがない
471
- // const existingOldKeyCount = await this.redisClient.exists(oldKey);
472
- // debug('existingOldKeyCount:', existingOldKeyCount);
473
- // if (existingOldKeyCount > 0) {
474
- // throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
475
- // }
476
- // oldの場合newが存在するはずがない
477
- // const existingNewKeyCount = await this.redisClient.exists(newKey);
478
- // debug('existingNewKeyCount:', existingNewKeyCount);
479
- // if (existingNewKeyCount > 0) {
480
- // throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
481
- // }
482
- }
483
- else {
484
- // collectionにdocumentが存在するはずがない
485
- // const existingHoldReservationCount = await this.holdReservationModel.count(
486
- // { 'reservationFor.id': { $eq: params.eventId } }
487
- // )
488
- // .exec();
489
- // debug('existingHoldReservationCount:', existingHoldReservationCount);
490
- // if (existingHoldReservationCount > 0) {
491
- // throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
492
- // }
493
- if (params.key !== oldKey) {
494
- // newの場合oldが存在するはずがない
495
- const existingOldKeyCount = yield this.redisClient.exists(oldKey);
496
- debug('existingOldKeyCount:', existingOldKeyCount);
497
- if (existingOldKeyCount > 0) {
498
- throw new factory.errors.ServiceUnavailable(`stockHolder keys conflicted. eventId:${params.eventId}`);
499
- }
500
- }
501
- if (params.key !== newKey) {
502
- // oldの場合newが存在するはずがない
503
- const existingNewKeyCount = yield this.redisClient.exists(newKey);
504
- debug('existingNewKeyCount:', existingNewKeyCount);
505
- if (existingNewKeyCount > 0) {
506
- throw new factory.errors.ServiceUnavailable(`stockHolder keys conflicted. eventId:${params.eventId}`);
507
- }
508
- }
509
- }
510
- });
511
- }
512
240
  }
513
241
  StockHolderRepository.KEY_PREFIX_NEW = 'stockHolder';
514
- StockHolderRepository.KEY_PREFIX = 'chevre:itemAvailability:screeningEvent';
515
242
  exports.StockHolderRepository = StockHolderRepository;
@@ -26,8 +26,6 @@ const debug = createDebug('chevre-domain:service');
26
26
  function aggregateScreeningEvent(params) {
27
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
28
  // 集計対象イベント検索
29
- // イベント取得属性最適化(2023-01-23~)
30
- // const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>(params);
31
29
  const event = yield repos.event.findMinimizedIndividualEventById(params);
32
30
  let aggregatingEvents = [event];
33
31
  // プロジェクト限定(2023-02-22~)
@@ -43,17 +41,34 @@ function aggregateScreeningEvent(params) {
43
41
  .add(1, 'hour')
44
42
  .add(-1, 'second')
45
43
  .toDate();
46
- // 取得属性最適化(2023-01-25~)
47
- aggregatingEvents = yield repos.event.search({
48
- limit: 100,
49
- page: 1,
50
- project: { id: { $eq: event.project.id } },
51
- typeOf: event.typeOf,
52
- eventStatuses: [factory.eventStatusType.EventScheduled],
53
- startFrom: startFrom,
54
- startThrough: startThrough,
55
- location: { branchCode: { $eq: event.location.branchCode } }
56
- }, event_1.PROJECTION_MINIMIZED_EVENT);
44
+ if (event.typeOf === factory.eventType.Event) {
45
+ aggregatingEvents = yield repos.event.search({
46
+ limit: 100,
47
+ page: 1,
48
+ project: { id: { $eq: event.project.id } },
49
+ typeOf: event.typeOf,
50
+ eventStatuses: [factory.eventStatusType.EventScheduled],
51
+ startFrom: startFrom,
52
+ startThrough: startThrough,
53
+ location: { branchCode: { $eq: event.location.branchCode } }
54
+ }, event_1.keyOfMinimizedEvent, []
55
+ // PROJECTION_MINIMIZED_EVENT
56
+ );
57
+ }
58
+ else if (event.typeOf === factory.eventType.ScreeningEvent) {
59
+ aggregatingEvents = yield repos.event.search({
60
+ limit: 100,
61
+ page: 1,
62
+ project: { id: { $eq: event.project.id } },
63
+ typeOf: event.typeOf,
64
+ eventStatuses: [factory.eventStatusType.EventScheduled],
65
+ startFrom: startFrom,
66
+ startThrough: startThrough,
67
+ location: { branchCode: { $eq: event.location.branchCode } }
68
+ }, event_1.keyOfMinimizedScreeningEvent, []
69
+ // PROJECTION_MINIMIZED_EVENT
70
+ );
71
+ }
57
72
  // ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
58
73
  aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
59
74
  aggregatingEvents = [event, ...aggregatingEvents];
@@ -100,18 +100,14 @@ function searchEventTicketOffersByEvent(params) {
100
100
  let soundFormatTypes = [];
101
101
  let videoFormatTypes = [];
102
102
  if (event.typeOf === factory.eventType.ScreeningEvent) {
103
- // 取得属性最適化(2023-01-25~)
104
- // const superEvent: Pick<factory.event.IEvent<factory.eventType.ScreeningEventSeries>, 'soundFormat' | 'videoFormat'> =
105
- // await repos.event.findById<factory.eventType.ScreeningEventSeries>(
106
- // { id: event.superEvent.id },
107
- // { soundFormat: 1, videoFormat: 1 }
108
- // );
109
103
  const superEvents = yield repos.event.search({
110
104
  limit: 1,
111
105
  page: 1,
112
106
  id: { $eq: event.superEvent.id },
113
107
  typeOf: factory.eventType.ScreeningEventSeries
114
- }, { soundFormat: 1, videoFormat: 1 });
108
+ }, ['soundFormat', 'videoFormat'], []
109
+ // { soundFormat: 1, videoFormat: 1 }
110
+ );
115
111
  const superEvent = superEvents.shift();
116
112
  if (superEvent === undefined) {
117
113
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
@@ -327,7 +323,9 @@ function searchOfferAppliesToMovieTicket(params) {
327
323
  page: 1,
328
324
  id: { $eq: event.superEvent.id },
329
325
  typeOf: factory.eventType.ScreeningEventSeries
330
- }, { soundFormat: 1, videoFormat: 1 });
326
+ }, ['soundFormat', 'videoFormat'], []
327
+ // { soundFormat: 1, videoFormat: 1 }
328
+ );
331
329
  const superEvent = superEvents.shift();
332
330
  if (superEvent === undefined) {
333
331
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
@@ -236,13 +236,31 @@ function createAggregateScreeningEventIfNotExist(params) {
236
236
  exports.createAggregateScreeningEventIfNotExist = createAggregateScreeningEventIfNotExist;
237
237
  function createInformTasks(params) {
238
238
  return (repos) => __awaiter(this, void 0, void 0, function* () {
239
- const events4inform = yield repos.event.search({
240
- id: { $in: params.ids },
241
- typeOf: params.typeOf
242
- }, {
243
- aggregateEntranceGate: 0, aggregateOffer: 0, aggregateReservation: 0,
244
- remainingAttendeeCapacity: 0, checkInCount: 0, attendeeCount: 0
245
- });
239
+ let events4inform;
240
+ if (params.typeOf === factory.eventType.Event) {
241
+ events4inform = yield repos.event.search({
242
+ id: { $in: params.ids },
243
+ typeOf: params.typeOf
244
+ }, [], [
245
+ 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
246
+ 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
247
+ ]);
248
+ }
249
+ else if (params.typeOf === factory.eventType.ScreeningEvent) {
250
+ events4inform = yield repos.event.search({
251
+ id: { $in: params.ids },
252
+ typeOf: params.typeOf
253
+ }, [], [
254
+ 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
255
+ 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
256
+ ]);
257
+ }
258
+ else {
259
+ events4inform = yield repos.event.search({
260
+ id: { $in: params.ids },
261
+ typeOf: params.typeOf
262
+ }, [], []);
263
+ }
246
264
  if (events4inform.length > 0) {
247
265
  const taskRunsAt = new Date();
248
266
  const informTasks = [];
@@ -114,7 +114,9 @@ function onReservationCheckedIn(params) {
114
114
  const existingEvents = yield repos.event.search({
115
115
  id: { $eq: reservationForId },
116
116
  typeOfIn: [factory.eventType.Event, factory.eventType.ScreeningEvent] // 指定しないとArgumentNullError
117
- }, { _id: 1 });
117
+ }, ['_id'], []
118
+ // { _id: 1 }
119
+ );
118
120
  if (existingEvents.length > 0) {
119
121
  yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
120
122
  project: { id: params.project.id },
@@ -53,9 +53,11 @@ function start(params) {
53
53
  events = yield repos.event.search({
54
54
  id: { $in: eventIds },
55
55
  typeOf: factory.eventType.ScreeningEvent
56
- }, {
57
- startDate: 1
58
- });
56
+ }, ['startDate'], []
57
+ // {
58
+ // startDate: 1
59
+ // }
60
+ );
59
61
  }
60
62
  let returnPolicies = seller.hasMerchantReturnPolicy;
61
63
  if (!Array.isArray(returnPolicies)) {
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.13.0"
120
+ "version": "21.15.0-alpha.0"
121
121
  }
@@ -1,21 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- const project = { id: process.env.PROJECT_ID };
7
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
-
11
- const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
12
-
13
- const result = await priceSpecificationRepo.deleteUnnecessaryMovieTicketTypeChargePriceSpecs({
14
- project: { id: project.id }
15
- });
16
- console.log('deleted', result);
17
- }
18
-
19
- main()
20
- .then()
21
- .catch(console.error);
@@ -1,76 +0,0 @@
1
- // tslint:disable:no-console
2
- // import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
- // const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
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 placeRepo = new chevre.repository.Place(mongoose.connection);
15
-
16
- const cursor = placeRepo.getCursor(
17
- {
18
- // 'project.id': { $eq: project.id },
19
- // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
20
- typeOf: {
21
- $eq: chevre.factory.placeType.MovieTheater
22
- }
23
- // organizer: { $exists: false }
24
- },
25
- {
26
- branchCode: 1,
27
- _id: 1, name: 1, project: 1, hasPOS: 1
28
- }
29
- );
30
- console.log('places found');
31
-
32
- let i = 0;
33
- let updateCount = 0;
34
- await cursor.eachAsync(async (doc) => {
35
- i += 1;
36
- const movieTheater: Pick<chevre.factory.place.movieTheater.IPlace,
37
- 'branchCode' | 'id' | 'name' | 'project' | 'hasPOS'> = doc.toObject();
38
- console.log(movieTheater);
39
-
40
- if (!Array.isArray(movieTheater.hasPOS)) {
41
- console.log('has no pos', movieTheater.project.id, movieTheater.branchCode, movieTheater.name.ja, i);
42
- } else {
43
- const alreadyMigrated = movieTheater.hasPOS.every((pos) => pos.branchCode === pos.id);
44
- if (alreadyMigrated) {
45
- console.log('already migrated...', movieTheater.project.id, movieTheater.branchCode, movieTheater.name.ja, i);
46
- } else {
47
- if (movieTheater.hasPOS.length > 0) {
48
- const newHasPOS: chevre.factory.place.movieTheater.IPOS[] = movieTheater.hasPOS.map((pos) => {
49
- return {
50
- id: pos.id,
51
- branchCode: pos.id,
52
- name: pos.name
53
- };
54
- });
55
- console.log('updating place...', movieTheater.project.id, movieTheater.branchCode, movieTheater.name.ja, i, newHasPOS);
56
- await placeRepo.saveMovieTheater(<any>{
57
- project: movieTheater.project,
58
- branchCode: movieTheater.branchCode,
59
- id: movieTheater.id,
60
- typeOf: chevre.factory.placeType.MovieTheater,
61
- hasPOS: newHasPOS
62
- });
63
- updateCount += 1;
64
- console.log('updated.', movieTheater.project.id, movieTheater.branchCode, movieTheater.name.ja, i);
65
- }
66
- }
67
- }
68
- });
69
-
70
- console.log(i, 'places checked');
71
- console.log(updateCount, 'places updated');
72
- }
73
-
74
- main()
75
- .then()
76
- .catch(console.error);