@chevre/domain 20.2.0-alpha.27 → 20.2.0-alpha.29

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.
@@ -12,37 +12,47 @@ async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
14
  const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
15
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
15
16
  const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
16
17
  const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
17
18
  const actionRepo = new chevre.repository.Action(mongoose.connection);
18
19
  const taskRepo = new chevre.repository.Task(mongoose.connection);
19
20
 
20
21
  await aggregationRepo.aggregationModel.deleteMany({
21
- typeOf: { $in: ['AggregateOrder', 'AggregateReservation', 'AggregatePay', 'AggregateReserve'] }
22
+ typeOf: { $in: ['AggregateOrder', 'AggregateReservation'] }
22
23
  })
23
24
  .exec();
24
- await chevre.service.aggregation.system.aggregateReserveTransaction({
25
+
26
+ await chevre.service.aggregation.system.aggregateEvent({
25
27
  aggregationDays: AGGREGATE_DAYS,
26
28
  excludedProjectId: EXCLUDED_PROJECT_ID
27
29
  })({
28
30
  agregation: aggregationRepo,
29
- assetTransaction: assetTransactionRepo
31
+ event: eventRepo
30
32
  });
31
33
 
32
- await chevre.service.aggregation.system.aggregatePayTransaction({
34
+ await chevre.service.aggregation.system.aggregateTask({
35
+ aggregationDays: AGGREGATE_DAYS,
36
+ excludedProjectId: EXCLUDED_PROJECT_ID
37
+ })({
38
+ agregation: aggregationRepo,
39
+ task: taskRepo
40
+ });
41
+
42
+ await chevre.service.aggregation.system.aggregateReserveTransaction({
33
43
  aggregationDays: AGGREGATE_DAYS,
34
44
  excludedProjectId: EXCLUDED_PROJECT_ID
35
45
  })({
36
46
  agregation: aggregationRepo,
37
47
  assetTransaction: assetTransactionRepo
38
48
  });
39
- // return;
40
- await chevre.service.aggregation.system.aggregateTask({
49
+
50
+ await chevre.service.aggregation.system.aggregatePayTransaction({
41
51
  aggregationDays: AGGREGATE_DAYS,
42
52
  excludedProjectId: EXCLUDED_PROJECT_ID
43
53
  })({
44
54
  agregation: aggregationRepo,
45
- task: taskRepo
55
+ assetTransaction: assetTransactionRepo
46
56
  });
47
57
 
48
58
  await chevre.service.aggregation.system.aggregatePlaceOrder({
@@ -0,0 +1,2 @@
1
+ import * as factory from '../factory';
2
+ export declare type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +1,12 @@
1
1
  import { Connection, Model } from 'mongoose';
2
2
  import * as factory from '../factory';
3
3
  export declare enum AggregationType {
4
- AggregatePlaceOrder = "AggregatePlaceOrder",
5
4
  AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
6
5
  AggregateAuthorizeOrderAction = "AggregateAuthorizeOrderAction",
7
6
  AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
7
+ AggregateEvent = "AggregateEvent",
8
8
  AggregatePay = "AggregatePay",
9
+ AggregatePlaceOrder = "AggregatePlaceOrder",
9
10
  AggregateReserve = "AggregateReserve",
10
11
  AggregateTask = "AggregateTask",
11
12
  AggregateUseAction = "AggregateUseAction"
@@ -24,11 +24,12 @@ exports.MongoRepository = exports.AggregationType = void 0;
24
24
  const aggregation_1 = require("./mongoose/model/aggregation");
25
25
  var AggregationType;
26
26
  (function (AggregationType) {
27
- AggregationType["AggregatePlaceOrder"] = "AggregatePlaceOrder";
28
27
  AggregationType["AggregateAuthorizeEventServiceOfferAction"] = "AggregateAuthorizeEventServiceOfferAction";
29
28
  AggregationType["AggregateAuthorizeOrderAction"] = "AggregateAuthorizeOrderAction";
30
29
  AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
30
+ AggregationType["AggregateEvent"] = "AggregateEvent";
31
31
  AggregationType["AggregatePay"] = "AggregatePay";
32
+ AggregationType["AggregatePlaceOrder"] = "AggregatePlaceOrder";
32
33
  AggregationType["AggregateReserve"] = "AggregateReserve";
33
34
  AggregationType["AggregateTask"] = "AggregateTask";
34
35
  AggregationType["AggregateUseAction"] = "AggregateUseAction";
@@ -1,5 +1,6 @@
1
1
  import { Connection } from 'mongoose';
2
2
  import * as factory from '../factory';
3
+ import * as EventFactory from '../factory/event';
3
4
  export interface IAttributes4patchUpdate<T extends factory.eventType> {
4
5
  typeOf: T;
5
6
  eventStatus?: factory.eventStatusType;
@@ -30,6 +31,28 @@ export interface IUpdateAggregateUseActionsParams {
30
31
  };
31
32
  }
32
33
  export declare type ISearchConditions<T extends factory.eventType> = factory.event.ISearchConditions<T>;
34
+ interface IAggregationByStatus {
35
+ eventCount: number;
36
+ reservationCount: number;
37
+ avgOfferCount: number;
38
+ maximumAttendeeCapacity: number;
39
+ remainingAttendeeCapacity: number;
40
+ avgRemainingCapacityRate: number;
41
+ maxRemainingCapacityRate: number;
42
+ minRemainingCapacityRate: number;
43
+ percentilesRemainingCapacityRate: {
44
+ name: string;
45
+ value: number;
46
+ }[];
47
+ }
48
+ interface IStatus {
49
+ status: factory.eventStatusType;
50
+ aggregation: IAggregationByStatus;
51
+ }
52
+ export interface IAggregateEvent {
53
+ statuses: IStatus[];
54
+ }
55
+ export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
33
56
  /**
34
57
  * イベントリポジトリ
35
58
  */
@@ -83,6 +106,9 @@ export declare class MongoRepository {
83
106
  }, projection?: {
84
107
  [key: string]: number;
85
108
  }): Promise<factory.event.IEvent<T>>;
109
+ findMinimizedIndividualEventById<T extends factory.eventType.ScreeningEvent | factory.eventType.Event>(params: {
110
+ id: string;
111
+ }): Promise<IMinimizedIndividualEvent<T>>;
86
112
  /**
87
113
  * イベントをキャンセルする
88
114
  */
@@ -108,4 +134,16 @@ export declare class MongoRepository {
108
134
  deleteUnnecessaryProjectAttributesById(params: {
109
135
  id: string;
110
136
  }): Promise<void>;
137
+ aggregateEvent(params: {
138
+ project?: {
139
+ id?: {
140
+ $ne?: string;
141
+ };
142
+ };
143
+ startFrom: Date;
144
+ startThrough: Date;
145
+ typeOf: factory.eventType;
146
+ }): Promise<IAggregateEvent>;
147
+ private agggregateByStatus;
111
148
  }
149
+ export {};
@@ -614,9 +614,32 @@ class MongoRepository {
614
614
  }
615
615
  findById(params, projection) {
616
616
  return __awaiter(this, void 0, void 0, function* () {
617
- const doc = yield this.eventModel.findOne({
618
- _id: params.id
619
- }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
617
+ const doc = yield this.eventModel.findOne({ _id: params.id }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
618
+ .exec();
619
+ if (doc === null) {
620
+ throw new factory.errors.NotFound(this.eventModel.modelName);
621
+ }
622
+ return doc.toObject();
623
+ });
624
+ }
625
+ findMinimizedIndividualEventById(params) {
626
+ return __awaiter(this, void 0, void 0, function* () {
627
+ const doc = yield this.eventModel.findOne({ _id: params.id }, {
628
+ project: 1,
629
+ _id: 1,
630
+ typeOf: 1,
631
+ additionalProperty: 1,
632
+ name: 1,
633
+ doorTime: 1,
634
+ endDate: 1,
635
+ eventStatus: 1,
636
+ location: 1,
637
+ startDate: 1,
638
+ superEvent: 1,
639
+ offers: 1,
640
+ coaInfo: 1,
641
+ identifier: 1
642
+ })
620
643
  .exec();
621
644
  if (doc === null) {
622
645
  throw new factory.errors.NotFound(this.eventModel.modelName);
@@ -687,5 +710,213 @@ class MongoRepository {
687
710
  .exec();
688
711
  });
689
712
  }
713
+ aggregateEvent(params) {
714
+ return __awaiter(this, void 0, void 0, function* () {
715
+ const statuses = yield Promise.all([
716
+ factory.eventStatusType.EventScheduled,
717
+ factory.eventStatusType.EventCancelled,
718
+ factory.eventStatusType.EventPostponed
719
+ ].map((eventStatus) => __awaiter(this, void 0, void 0, function* () {
720
+ var _a, _b;
721
+ const matchConditions = Object.assign({ startDate: {
722
+ $gte: params.startFrom,
723
+ $lte: params.startThrough
724
+ }, typeOf: { $eq: params.typeOf }, eventStatus: { $eq: eventStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
725
+ ? { 'project.id': { $ne: params.project.id.$ne } }
726
+ : undefined);
727
+ return this.agggregateByStatus({ matchConditions, status: eventStatus });
728
+ })));
729
+ return { statuses };
730
+ });
731
+ }
732
+ // tslint:disable-next-line:max-func-body-length
733
+ agggregateByStatus(params) {
734
+ return __awaiter(this, void 0, void 0, function* () {
735
+ const matchConditions = params.matchConditions;
736
+ const eventStatus = params.status;
737
+ const aggregations = yield this.eventModel.aggregate([
738
+ {
739
+ $match: matchConditions
740
+ },
741
+ {
742
+ $project: {
743
+ remainingCapacityRate: {
744
+ $cond: {
745
+ if: {
746
+ $and: [
747
+ { $isNumber: '$maximumAttendeeCapacity' },
748
+ { $isNumber: '$remainingAttendeeCapacity' }
749
+ ]
750
+ },
751
+ then: {
752
+ $cond: {
753
+ if: { $gt: ['$maximumAttendeeCapacity', 0] },
754
+ then: {
755
+ $multiply: [
756
+ { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
757
+ // tslint:disable-next-line:no-magic-numbers
758
+ 100
759
+ ]
760
+ },
761
+ else: 0
762
+ }
763
+ },
764
+ else: 0
765
+ }
766
+ },
767
+ eventStatus: '$eventStatus',
768
+ startDate: '$startDate',
769
+ endDate: '$endDate',
770
+ typeOf: '$typeOf',
771
+ maximumAttendeeCapacity: {
772
+ $cond: {
773
+ if: { $isNumber: '$maximumAttendeeCapacity' },
774
+ then: '$maximumAttendeeCapacity',
775
+ else: 0
776
+ }
777
+ },
778
+ remainingAttendeeCapacity: {
779
+ $cond: {
780
+ if: { $isNumber: '$remainingAttendeeCapacity' },
781
+ then: '$remainingAttendeeCapacity',
782
+ else: 0
783
+ }
784
+ },
785
+ reservationCount: {
786
+ $cond: {
787
+ if: { $isNumber: '$aggregateReservation.reservationCount' },
788
+ then: '$aggregateReservation.reservationCount',
789
+ else: 0
790
+ }
791
+ },
792
+ offerCount: {
793
+ $cond: {
794
+ if: { $isNumber: '$aggregateOffer.offerCount' },
795
+ then: '$aggregateOffer.offerCount',
796
+ else: 0
797
+ }
798
+ }
799
+ }
800
+ },
801
+ {
802
+ $group: {
803
+ _id: '$typeOf',
804
+ eventCount: { $sum: 1 },
805
+ reservationCount: { $sum: '$reservationCount' },
806
+ avgOfferCount: { $avg: '$offerCount' },
807
+ maximumAttendeeCapacity: { $sum: '$maximumAttendeeCapacity' },
808
+ remainingAttendeeCapacity: { $sum: '$remainingAttendeeCapacity' },
809
+ avgRemainingCapacityRate: { $avg: '$remainingCapacityRate' },
810
+ maxRemainingCapacityRate: { $max: '$remainingCapacityRate' },
811
+ minRemainingCapacityRate: { $min: '$remainingCapacityRate' }
812
+ }
813
+ },
814
+ {
815
+ $project: {
816
+ _id: 0,
817
+ eventCount: '$eventCount',
818
+ reservationCount: '$reservationCount',
819
+ avgOfferCount: '$avgOfferCount',
820
+ maximumAttendeeCapacity: '$maximumAttendeeCapacity',
821
+ remainingAttendeeCapacity: '$remainingAttendeeCapacity',
822
+ avgRemainingCapacityRate: '$avgRemainingCapacityRate',
823
+ maxRemainingCapacityRate: '$maxRemainingCapacityRate',
824
+ minRemainingCapacityRate: '$minRemainingCapacityRate'
825
+ }
826
+ }
827
+ ])
828
+ .exec();
829
+ // tslint:disable-next-line:no-magic-numbers
830
+ const percents = [50, 95, 99];
831
+ if (aggregations.length === 0) {
832
+ return {
833
+ status: eventStatus,
834
+ aggregation: {
835
+ eventCount: 0,
836
+ reservationCount: 0,
837
+ avgOfferCount: 0,
838
+ maximumAttendeeCapacity: 0,
839
+ remainingAttendeeCapacity: 0,
840
+ avgRemainingCapacityRate: 0,
841
+ maxRemainingCapacityRate: 0,
842
+ minRemainingCapacityRate: 0,
843
+ percentilesRemainingCapacityRate: percents.map((percent) => {
844
+ return {
845
+ name: String(percent),
846
+ value: 0
847
+ };
848
+ })
849
+ }
850
+ };
851
+ }
852
+ const ranks4percentile = percents.map((percentile) => {
853
+ return {
854
+ percentile,
855
+ // tslint:disable-next-line:no-magic-numbers
856
+ rank: Math.floor(aggregations[0].eventCount * percentile / 100)
857
+ };
858
+ });
859
+ const aggregations2 = yield this.eventModel.aggregate([
860
+ {
861
+ $match: matchConditions
862
+ },
863
+ {
864
+ $project: {
865
+ remainingCapacityRate: {
866
+ $cond: {
867
+ if: {
868
+ $and: [
869
+ { $isNumber: '$maximumAttendeeCapacity' },
870
+ { $isNumber: '$remainingAttendeeCapacity' }
871
+ ]
872
+ },
873
+ then: {
874
+ $cond: {
875
+ if: { $gt: ['$maximumAttendeeCapacity', 0] },
876
+ then: {
877
+ $multiply: [
878
+ { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
879
+ // tslint:disable-next-line:no-magic-numbers
880
+ 100
881
+ ]
882
+ },
883
+ else: 0
884
+ }
885
+ },
886
+ else: 0
887
+ }
888
+ },
889
+ eventStatus: '$eventStatus',
890
+ startDate: '$startDate',
891
+ endDate: '$endDate',
892
+ typeOf: '$typeOf'
893
+ }
894
+ },
895
+ { $sort: { remainingCapacityRate: 1 } },
896
+ {
897
+ $group: {
898
+ _id: '$typeOf',
899
+ remainingCapacityRates: { $push: '$remainingCapacityRate' }
900
+ }
901
+ },
902
+ {
903
+ $project: {
904
+ _id: 0,
905
+ percentilesRemainingCapacityRate: ranks4percentile.map((rank) => {
906
+ return {
907
+ name: String(rank.percentile),
908
+ value: { $arrayElemAt: ['$remainingCapacityRates', rank.rank] }
909
+ };
910
+ })
911
+ }
912
+ }
913
+ ])
914
+ .exec();
915
+ return {
916
+ status: eventStatus,
917
+ aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
918
+ };
919
+ });
920
+ }
690
921
  }
691
922
  exports.MongoRepository = MongoRepository;
@@ -35,7 +35,8 @@ const schema = new mongoose.Schema({
35
35
  subtitleLanguage: mongoose.SchemaTypes.Mixed,
36
36
  dubLanguage: mongoose.SchemaTypes.Mixed,
37
37
  kanaName: String,
38
- hasOfferCatalog: mongoose.SchemaTypes.Mixed,
38
+ // 不要なので廃止(2023-01-23~)
39
+ // hasOfferCatalog: mongoose.SchemaTypes.Mixed,
39
40
  offers: mongoose.SchemaTypes.Mixed,
40
41
  maximumAttendeeCapacity: { type: Number },
41
42
  remainingAttendeeCapacity: { type: Number },
@@ -23,7 +23,9 @@ const debug = createDebug('chevre-domain:service');
23
23
  function aggregateScreeningEvent(params) {
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
25
  // 集計対象イベント検索
26
- const event = yield repos.event.findById(params);
26
+ // イベント取得属性最適化(2023-01-23~)
27
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>(params);
28
+ const event = yield repos.event.findMinimizedIndividualEventById(params);
27
29
  let aggregatingEvents = [event];
28
30
  const availableOffers = yield findOffers({ event })(repos);
29
31
  const offerRateLimitExists = availableOffers.some((o) => { var _a; return typeof ((_a = o.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope) === 'string'; });
@@ -20,7 +20,9 @@ function aggregateUseActionsOnEvent(params) {
20
20
  return (repos) => __awaiter(this, void 0, void 0, function* () {
21
21
  const now = new Date();
22
22
  // 集計対象イベント検索
23
- const event = yield repos.event.findById(params);
23
+ // イベント取得属性最適化(2023-01-23~)
24
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent>(params);
25
+ const event = yield repos.event.findMinimizedIndividualEventById(params);
24
26
  // 入場ゲート検索
25
27
  const entranceGates = yield findEntranceGates({ event })(repos);
26
28
  // 入場ゲートごとの集計
@@ -1,8 +1,16 @@
1
1
  import { MongoRepository as ActionRepo } from '../../repo/action';
2
2
  import { MongoRepository as AggregationRepo } from '../../repo/aggregation';
3
3
  import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
4
+ import { MongoRepository as EventRepo } from '../../repo/event';
4
5
  import { MongoRepository as TasKRepo } from '../../repo/task';
5
6
  import { MongoRepository as TransactionRepo } from '../../repo/transaction';
7
+ declare function aggregateEvent(params: {
8
+ aggregationDays: number;
9
+ excludedProjectId?: string;
10
+ }): (repos: {
11
+ agregation: AggregationRepo;
12
+ event: EventRepo;
13
+ }) => Promise<void>;
6
14
  /**
7
15
  * 注文取引集計
8
16
  */
@@ -75,4 +83,4 @@ declare function aggregateTask(params: {
75
83
  agregation: AggregationRepo;
76
84
  task: TasKRepo;
77
85
  }) => Promise<void>;
78
- export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
86
+ export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateEvent, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
@@ -9,12 +9,45 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.aggregateUseAction = exports.aggregateTask = exports.aggregateReserveTransaction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
12
+ exports.aggregateUseAction = exports.aggregateTask = exports.aggregateReserveTransaction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = exports.aggregateEvent = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
13
13
  const createDebug = require("debug");
14
14
  const moment = require("moment-timezone");
15
15
  const factory = require("../../factory");
16
16
  const aggregation_1 = require("../../repo/aggregation");
17
17
  const debug = createDebug('chevre-domain:service:aggregation:system');
18
+ function aggregateEvent(params) {
19
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
20
+ var _a;
21
+ const aggregateDate = new Date();
22
+ const aggregateDuration = moment.duration(1, 'days')
23
+ .toISOString();
24
+ let i = -1;
25
+ while (i < params.aggregationDays) {
26
+ i += 1;
27
+ const startFrom = moment()
28
+ .utc()
29
+ // .tz('Asia/Tokyo')
30
+ .add(-i, 'days')
31
+ .startOf('day')
32
+ .toDate();
33
+ const startThrough = moment()
34
+ .utc()
35
+ // .tz('Asia/Tokyo')
36
+ .add(-i, 'days')
37
+ .endOf('day')
38
+ .toDate();
39
+ const aggregateResult = yield repos.event.aggregateEvent({
40
+ project: { id: { $ne: params.excludedProjectId } },
41
+ startFrom,
42
+ startThrough,
43
+ typeOf: factory.eventType.ScreeningEvent
44
+ });
45
+ debug('aggregateEvent:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesRemainingCapacityRate, startFrom);
46
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateEvent, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
47
+ }
48
+ });
49
+ }
50
+ exports.aggregateEvent = aggregateEvent;
18
51
  /**
19
52
  * 注文取引集計
20
53
  */
@@ -38,7 +38,11 @@ function validateMovieTicket(params, paymentServiceId) {
38
38
  throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
39
39
  }
40
40
  // イベント情報取得
41
- const screeningEvent = yield repos.event.findById({
41
+ // イベント取得属性最適化(2023-01-23~)
42
+ // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({
43
+ // id: eventIds[0]
44
+ // });
45
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
42
46
  id: eventIds[0]
43
47
  });
44
48
  // 販売者からムビチケ決済情報取得
@@ -72,11 +72,16 @@ function addReservations(params) {
72
72
  throw new factory.errors.ArgumentNull('object.reservationFor.id');
73
73
  }
74
74
  const acceptedOffers = (Array.isArray(params.object.acceptedOffer)) ? params.object.acceptedOffer : [];
75
- const event = yield repos.event.findById({ id: params.object.reservationFor.id }, {
76
- // 予約データに不要な属性は取得しない
77
- aggregateReservation: 0, aggregateOffer: 0, attendeeCount: 0,
78
- checkInCount: 0, maximumAttendeeCapacity: 0, remainingAttendeeCapacity: 0
79
- });
75
+ // イベント取得属性最適化(2023-01-23~)
76
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.object.reservationFor.id });
77
+ // const event = await repos.event.findById(
78
+ // { id: params.object.reservationFor.id },
79
+ // {
80
+ // // 予約データに不要な属性は取得しない
81
+ // aggregateReservation: 0, aggregateOffer: 0, attendeeCount: 0,
82
+ // checkInCount: 0, maximumAttendeeCapacity: 0, remainingAttendeeCapacity: 0
83
+ // }
84
+ // );
80
85
  if (event.typeOf !== factory.eventType.ScreeningEvent && event.typeOf !== factory.eventType.Event) {
81
86
  throw new factory.errors.Argument('object.reservationFor.id', `invalid event type ${event.typeOf}`);
82
87
  }
@@ -124,7 +124,11 @@ function validateCreateRequest(params) {
124
124
  if (typeof ((_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.id) !== 'string' || params.object.reservationFor.id.length === 0) {
125
125
  throw new factory.errors.ArgumentNull('object.reservationFor.id');
126
126
  }
127
- const event = yield repos.event.findById({ id: params.object.reservationFor.id });
127
+ // イベント取得属性最適化(2023-01-23~)
128
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.reservationFor.id });
129
+ const event = yield repos.event.findMinimizedIndividualEventById({
130
+ id: params.object.reservationFor.id
131
+ });
128
132
  let offeredThrough = (_b = event.offers) === null || _b === void 0 ? void 0 : _b.offeredThrough;
129
133
  if (offeredThrough === undefined) {
130
134
  offeredThrough = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
@@ -1,5 +1,6 @@
1
1
  import * as COA from '@motionpicture/coa-service';
2
2
  import * as factory from '../../../factory';
3
+ import { IMinimizedIndividualEvent } from '../../../factory/event';
3
4
  export declare type IReservationFor = factory.reservation.IReservationFor<factory.reservationType.EventReservation>;
4
5
  export declare type IUnitPriceSpecification = factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.UnitPriceSpecification>;
5
6
  export declare type IObjectWithoutDetail = factory.action.authorize.offer.seatReservation.IObjectWithoutDetail4chevre;
@@ -14,7 +15,7 @@ export declare function createReserveTransactionStartParams(params: {
14
15
  }): factory.assetTransaction.reserve.IStartParamsWithoutDetail;
15
16
  export declare function createAuthorizeSeatReservationActionAttributes(params: {
16
17
  acceptedOffers: factory.action.authorize.offer.seatReservation.IAcceptedOffer4chevre[];
17
- event: factory.event.IEvent<factory.eventType.ScreeningEvent>;
18
+ event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
18
19
  pendingTransaction?: factory.action.authorize.offer.seatReservation.IPendingTransaction | undefined;
19
20
  transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
20
21
  broker?: factory.reservation.IBroker<factory.reservationType.EventReservation>;
@@ -25,7 +26,7 @@ export declare function acceptedOffers2amount(params: {
25
26
  declare type IResultAcceptedOffer = factory.action.authorize.offer.seatReservation.IResultAcceptedOffer;
26
27
  export declare function responseBody2acceptedOffers4result(params: {
27
28
  responseBody: factory.assetTransaction.reserve.ITransaction;
28
- event: factory.event.IEvent<factory.eventType.ScreeningEvent>;
29
+ event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
29
30
  project: {
30
31
  id: string;
31
32
  typeOf: factory.organizationType.Project;
@@ -20,7 +20,8 @@ function searchTransportationEventTicketOffers(params) {
20
20
  // tslint:disable-next-line:max-func-body-length
21
21
  return (repos) => __awaiter(this, void 0, void 0, function* () {
22
22
  var _a, _b, _c;
23
- const screeningEvent = yield repos.event.findById({ id: params.eventId });
23
+ // const screeningEvent = await repos.event.findById<factory.eventType.Event>({ id: params.eventId });
24
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({ id: params.eventId });
24
25
  const soundFormatTypes = [];
25
26
  const videoFormatTypes = [];
26
27
  let availableOffers = [];
@@ -126,7 +127,9 @@ function searchScreeningEventTicketOffers(params) {
126
127
  // tslint:disable-next-line:max-func-body-length
127
128
  return (repos) => __awaiter(this, void 0, void 0, function* () {
128
129
  var _a, _b, _c;
129
- const screeningEvent = yield repos.event.findById({ id: params.eventId });
130
+ // イベント取得属性最適化(2023-01-23~)
131
+ // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.eventId });
132
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({ id: params.eventId });
130
133
  const superEvent = yield repos.event.findById({ id: screeningEvent.superEvent.id });
131
134
  const soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
132
135
  const videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
@@ -349,7 +352,11 @@ function searchEventTicketOffers(params) {
349
352
  var _a;
350
353
  const now = moment();
351
354
  let event;
352
- event = yield repos.event.findById({ id: params.event.id });
355
+ // イベント取得属性最適化(2023-01-23~)
356
+ // event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({ id: params.event.id });
357
+ event = yield repos.event.findMinimizedIndividualEventById({
358
+ id: params.event.id
359
+ });
353
360
  let offers;
354
361
  const eventOffers = event.offers;
355
362
  if (eventOffers === undefined) {
@@ -1,4 +1,5 @@
1
1
  import * as factory from '../../../factory';
2
+ import { IMinimizedIndividualEvent } from '../../../factory/event';
2
3
  export import WebAPIIdentifier = factory.service.webAPI.Identifier;
3
4
  export declare function createAuthorizeSeatReservationActionAttributes(params: {
4
5
  acceptedOffers: factory.action.authorize.offer.seatReservation.IAcceptedOffer<factory.service.webAPI.Identifier.COA>[];
@@ -19,7 +20,7 @@ declare type IResultAcceptedOffer = factory.action.authorize.offer.seatReservati
19
20
  export declare function responseBody2acceptedOffers4result(params: {
20
21
  responseBody: factory.action.authorize.offer.seatReservation.IResponseBody<factory.service.webAPI.Identifier.COA>;
21
22
  object: factory.action.authorize.offer.seatReservation.IObject<factory.service.webAPI.Identifier.COA>;
22
- event: factory.event.IEvent<factory.eventType.ScreeningEvent>;
23
+ event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
23
24
  seller: factory.transaction.placeOrder.ISeller;
24
25
  bookingTime: Date;
25
26
  totalPrice: number;
@@ -27,7 +27,11 @@ function authorize(params) {
27
27
  if (transaction.agent.id !== params.agent.id) {
28
28
  throw new factory.errors.Forbidden('Transaction not yours');
29
29
  }
30
- const screeningEvent = yield repos.event.findById({ id: params.object.event.id });
30
+ // イベント取得属性最適化(2023-01-23~)
31
+ // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.event.id });
32
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
33
+ id: params.object.event.id
34
+ });
31
35
  // 必ず定義されている前提
32
36
  // const coaInfo = <factory.event.screeningEvent.ICOAInfo>screeningEvent.coaInfo;
33
37
  // const acceptedOffersWithoutDetails = await createAcceptedOffersWithoutDetails({
@@ -158,7 +162,11 @@ function changeOffers(params) {
158
162
  throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
159
163
  }
160
164
  validate4changeOffer({ action: authorizeAction, object: params.object });
161
- const screeningEvent = yield repos.event.findById({ id: params.object.event.id });
165
+ // イベント取得属性最適化(2023-01-23~)
166
+ // const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.event.id });
167
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
168
+ id: params.object.event.id
169
+ });
162
170
  // COA仮予約後にリクエストが来る前提
163
171
  const acceptedOffer = params.object.acceptedOffer;
164
172
  // 座席区分加算料金などを補完
@@ -69,7 +69,11 @@ function searchEventSeatOffers(params) {
69
69
  return (repos) => __awaiter(this, void 0, void 0, function* () {
70
70
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
71
71
  let offers = [];
72
- const event = yield repos.event.findById({
72
+ // イベント取得属性最適化(2023-01-23~)
73
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({
74
+ // id: params.event.id
75
+ // });
76
+ const event = yield repos.event.findMinimizedIndividualEventById({
73
77
  id: params.event.id
74
78
  });
75
79
  // 座席指定利用可能かどうか
@@ -139,7 +143,11 @@ function searchEventSeatOffersWithPaging(params) {
139
143
  return (repos) => __awaiter(this, void 0, void 0, function* () {
140
144
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
141
145
  let offers = [];
142
- const event = yield repos.event.findById({
146
+ // イベント取得属性最適化(2023-01-23~)
147
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({
148
+ // id: params.event.id
149
+ // });
150
+ const event = yield repos.event.findMinimizedIndividualEventById({
143
151
  id: params.event.id
144
152
  });
145
153
  // 座席指定利用可能かどうか
@@ -1,6 +1,6 @@
1
1
  import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
2
2
  import { MongoRepository as ActionRepo } from '../../repo/action';
3
- import { MongoRepository as EventRepo } from '../../repo/event';
3
+ import { IMinimizedIndividualEvent, MongoRepository as EventRepo } from '../../repo/event';
4
4
  import { MongoRepository as ProductRepo } from '../../repo/product';
5
5
  import { MongoRepository as ProjectRepo } from '../../repo/project';
6
6
  import { MongoRepository as SellerRepo } from '../../repo/seller';
@@ -50,7 +50,7 @@ declare function checkMovieTicket(params: factory.action.check.paymentMethod.mov
50
50
  declare function checkByIdentifier(params: {
51
51
  movieTickets: IMovieTicket[];
52
52
  seller: factory.seller.ISeller;
53
- screeningEvent: factory.event.IEvent<factory.eventType.ScreeningEvent>;
53
+ screeningEvent: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
54
54
  paymentServiceId: string;
55
55
  }): (repos: {
56
56
  product: ProductRepo;
@@ -53,7 +53,11 @@ function checkMovieTicket(params) {
53
53
  }
54
54
  // イベント情報取得
55
55
  let screeningEvent;
56
- screeningEvent = yield repos.event.findById({
56
+ // イベント取得属性最適化(2023-01-23~)
57
+ // screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({
58
+ // id: eventIds[0]
59
+ // });
60
+ screeningEvent = yield repos.event.findMinimizedIndividualEventById({
57
61
  id: eventIds[0]
58
62
  });
59
63
  // ショップ情報取得
@@ -432,7 +436,9 @@ function payActionParams2seatInfoSyncIn(params) {
432
436
  if (eventIds.length !== 1) {
433
437
  throw new factory.errors.Argument('movieTickets', 'Number of events must be 1');
434
438
  }
435
- const event = yield repos.event.findById({ id: eventIds[0] });
439
+ // イベント取得属性最適化(2023-01-23~)
440
+ // const event = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: eventIds[0] });
441
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: eventIds[0] });
436
442
  const seller = yield repos.seller.findById({ id: String((_d = params.recipient) === null || _d === void 0 ? void 0 : _d.id) });
437
443
  // 全購入管理番号のMovieTicketをマージ
438
444
  const movieTickets = params.object.reduce((a, b) => [...a, ...(Array.isArray(b.movieTickets)) ? b.movieTickets : []], []);
package/package.json CHANGED
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.2.0-alpha.27"
123
+ "version": "20.2.0-alpha.29"
124
124
  }