@chevre/domain 20.2.0-alpha.26 → 20.2.0-alpha.28

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 (28) hide show
  1. package/example/src/chevre/aggregation/aggregateSystem.ts +17 -7
  2. package/example/src/chevre/migrateProjectSubscription.ts +51 -0
  3. package/lib/chevre/factory/event.d.ts +2 -0
  4. package/lib/chevre/factory/event.js +2 -0
  5. package/lib/chevre/repo/aggregation.d.ts +2 -1
  6. package/lib/chevre/repo/aggregation.js +2 -1
  7. package/lib/chevre/repo/event.d.ts +38 -0
  8. package/lib/chevre/repo/event.js +233 -3
  9. package/lib/chevre/repo/mongoose/model/event.js +2 -1
  10. package/lib/chevre/repo/mongoose/model/project.js +7 -1
  11. package/lib/chevre/repo/project.d.ts +4 -1
  12. package/lib/chevre/repo/project.js +9 -10
  13. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -1
  14. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
  15. package/lib/chevre/service/aggregation/system.d.ts +9 -1
  16. package/lib/chevre/service/aggregation/system.js +34 -1
  17. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  18. package/lib/chevre/service/assetTransaction/reserve.js +10 -5
  19. package/lib/chevre/service/offer/event/authorize.js +5 -1
  20. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  21. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +10 -3
  22. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  23. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  24. package/lib/chevre/service/offer.js +10 -2
  25. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  26. package/lib/chevre/service/payment/movieTicket.js +8 -2
  27. package/package.json +1 -1
  28. package/example/src/chevre/migratePaymentServicePaymentUrlExpiresInSeconds.ts +0 -77
@@ -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,51 @@
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
+ // tslint:disable-next-line:max-func-body-length
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const projectRepo = new chevre.repository.Project(mongoose.connection);
12
+
13
+ const cursor = projectRepo.getCursor(
14
+ {
15
+ },
16
+ {
17
+ // _id: 1,
18
+ }
19
+ );
20
+ console.log('projects found');
21
+
22
+ let i = 0;
23
+ let updateCount = 0;
24
+ // tslint:disable-next-line:max-func-body-length
25
+ await cursor.eachAsync(async (doc) => {
26
+ i += 1;
27
+ const project: chevre.factory.project.IProject = doc.toObject();
28
+
29
+ const useEventServiceAsProduct = project.subscription?.useEventServiceAsProduct;
30
+ const alreadyMigrated = useEventServiceAsProduct === true;
31
+
32
+ if (alreadyMigrated) {
33
+ console.log('already migrated.', project.id, i);
34
+ } else {
35
+ console.log(
36
+ 'updating product...', project.id, i);
37
+ await projectRepo.findByIdAndIUpdate({
38
+ id: project.id,
39
+ subscription: { useEventServiceAsProduct: true }
40
+ });
41
+ updateCount += 1;
42
+ console.log('updated...', project.id, i);
43
+ }
44
+ });
45
+ console.log(i, 'projects checked');
46
+ console.log(updateCount, 'projects updated');
47
+ }
48
+
49
+ main()
50
+ .then()
51
+ .catch(console.error);
@@ -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,31 @@ 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
+ name: 1,
632
+ doorTime: 1,
633
+ endDate: 1,
634
+ eventStatus: 1,
635
+ location: 1,
636
+ startDate: 1,
637
+ superEvent: 1,
638
+ offers: 1,
639
+ coaInfo: 1,
640
+ identifier: 1
641
+ })
620
642
  .exec();
621
643
  if (doc === null) {
622
644
  throw new factory.errors.NotFound(this.eventModel.modelName);
@@ -687,5 +709,213 @@ class MongoRepository {
687
709
  .exec();
688
710
  });
689
711
  }
712
+ aggregateEvent(params) {
713
+ return __awaiter(this, void 0, void 0, function* () {
714
+ const statuses = yield Promise.all([
715
+ factory.eventStatusType.EventScheduled,
716
+ factory.eventStatusType.EventCancelled,
717
+ factory.eventStatusType.EventPostponed
718
+ ].map((eventStatus) => __awaiter(this, void 0, void 0, function* () {
719
+ var _a, _b;
720
+ const matchConditions = Object.assign({ startDate: {
721
+ $gte: params.startFrom,
722
+ $lte: params.startThrough
723
+ }, 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')
724
+ ? { 'project.id': { $ne: params.project.id.$ne } }
725
+ : undefined);
726
+ return this.agggregateByStatus({ matchConditions, status: eventStatus });
727
+ })));
728
+ return { statuses };
729
+ });
730
+ }
731
+ // tslint:disable-next-line:max-func-body-length
732
+ agggregateByStatus(params) {
733
+ return __awaiter(this, void 0, void 0, function* () {
734
+ const matchConditions = params.matchConditions;
735
+ const eventStatus = params.status;
736
+ const aggregations = yield this.eventModel.aggregate([
737
+ {
738
+ $match: matchConditions
739
+ },
740
+ {
741
+ $project: {
742
+ remainingCapacityRate: {
743
+ $cond: {
744
+ if: {
745
+ $and: [
746
+ { $isNumber: '$maximumAttendeeCapacity' },
747
+ { $isNumber: '$remainingAttendeeCapacity' }
748
+ ]
749
+ },
750
+ then: {
751
+ $cond: {
752
+ if: { $gt: ['$maximumAttendeeCapacity', 0] },
753
+ then: {
754
+ $multiply: [
755
+ { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
756
+ // tslint:disable-next-line:no-magic-numbers
757
+ 100
758
+ ]
759
+ },
760
+ else: 0
761
+ }
762
+ },
763
+ else: 0
764
+ }
765
+ },
766
+ eventStatus: '$eventStatus',
767
+ startDate: '$startDate',
768
+ endDate: '$endDate',
769
+ typeOf: '$typeOf',
770
+ maximumAttendeeCapacity: {
771
+ $cond: {
772
+ if: { $isNumber: '$maximumAttendeeCapacity' },
773
+ then: '$maximumAttendeeCapacity',
774
+ else: 0
775
+ }
776
+ },
777
+ remainingAttendeeCapacity: {
778
+ $cond: {
779
+ if: { $isNumber: '$remainingAttendeeCapacity' },
780
+ then: '$remainingAttendeeCapacity',
781
+ else: 0
782
+ }
783
+ },
784
+ reservationCount: {
785
+ $cond: {
786
+ if: { $isNumber: '$aggregateReservation.reservationCount' },
787
+ then: '$aggregateReservation.reservationCount',
788
+ else: 0
789
+ }
790
+ },
791
+ offerCount: {
792
+ $cond: {
793
+ if: { $isNumber: '$aggregateOffer.offerCount' },
794
+ then: '$aggregateOffer.offerCount',
795
+ else: 0
796
+ }
797
+ }
798
+ }
799
+ },
800
+ {
801
+ $group: {
802
+ _id: '$typeOf',
803
+ eventCount: { $sum: 1 },
804
+ reservationCount: { $sum: '$reservationCount' },
805
+ avgOfferCount: { $avg: '$offerCount' },
806
+ maximumAttendeeCapacity: { $sum: '$maximumAttendeeCapacity' },
807
+ remainingAttendeeCapacity: { $sum: '$remainingAttendeeCapacity' },
808
+ avgRemainingCapacityRate: { $avg: '$remainingCapacityRate' },
809
+ maxRemainingCapacityRate: { $max: '$remainingCapacityRate' },
810
+ minRemainingCapacityRate: { $min: '$remainingCapacityRate' }
811
+ }
812
+ },
813
+ {
814
+ $project: {
815
+ _id: 0,
816
+ eventCount: '$eventCount',
817
+ reservationCount: '$reservationCount',
818
+ avgOfferCount: '$avgOfferCount',
819
+ maximumAttendeeCapacity: '$maximumAttendeeCapacity',
820
+ remainingAttendeeCapacity: '$remainingAttendeeCapacity',
821
+ avgRemainingCapacityRate: '$avgRemainingCapacityRate',
822
+ maxRemainingCapacityRate: '$maxRemainingCapacityRate',
823
+ minRemainingCapacityRate: '$minRemainingCapacityRate'
824
+ }
825
+ }
826
+ ])
827
+ .exec();
828
+ // tslint:disable-next-line:no-magic-numbers
829
+ const percents = [50, 95, 99];
830
+ if (aggregations.length === 0) {
831
+ return {
832
+ status: eventStatus,
833
+ aggregation: {
834
+ eventCount: 0,
835
+ reservationCount: 0,
836
+ avgOfferCount: 0,
837
+ maximumAttendeeCapacity: 0,
838
+ remainingAttendeeCapacity: 0,
839
+ avgRemainingCapacityRate: 0,
840
+ maxRemainingCapacityRate: 0,
841
+ minRemainingCapacityRate: 0,
842
+ percentilesRemainingCapacityRate: percents.map((percent) => {
843
+ return {
844
+ name: String(percent),
845
+ value: 0
846
+ };
847
+ })
848
+ }
849
+ };
850
+ }
851
+ const ranks4percentile = percents.map((percentile) => {
852
+ return {
853
+ percentile,
854
+ // tslint:disable-next-line:no-magic-numbers
855
+ rank: Math.floor(aggregations[0].eventCount * percentile / 100)
856
+ };
857
+ });
858
+ const aggregations2 = yield this.eventModel.aggregate([
859
+ {
860
+ $match: matchConditions
861
+ },
862
+ {
863
+ $project: {
864
+ remainingCapacityRate: {
865
+ $cond: {
866
+ if: {
867
+ $and: [
868
+ { $isNumber: '$maximumAttendeeCapacity' },
869
+ { $isNumber: '$remainingAttendeeCapacity' }
870
+ ]
871
+ },
872
+ then: {
873
+ $cond: {
874
+ if: { $gt: ['$maximumAttendeeCapacity', 0] },
875
+ then: {
876
+ $multiply: [
877
+ { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
878
+ // tslint:disable-next-line:no-magic-numbers
879
+ 100
880
+ ]
881
+ },
882
+ else: 0
883
+ }
884
+ },
885
+ else: 0
886
+ }
887
+ },
888
+ eventStatus: '$eventStatus',
889
+ startDate: '$startDate',
890
+ endDate: '$endDate',
891
+ typeOf: '$typeOf'
892
+ }
893
+ },
894
+ { $sort: { remainingCapacityRate: 1 } },
895
+ {
896
+ $group: {
897
+ _id: '$typeOf',
898
+ remainingCapacityRates: { $push: '$remainingCapacityRate' }
899
+ }
900
+ },
901
+ {
902
+ $project: {
903
+ _id: 0,
904
+ percentilesRemainingCapacityRate: ranks4percentile.map((rank) => {
905
+ return {
906
+ name: String(rank.percentile),
907
+ value: { $arrayElemAt: ['$remainingCapacityRates', rank.rank] }
908
+ };
909
+ })
910
+ }
911
+ }
912
+ ])
913
+ .exec();
914
+ return {
915
+ status: eventStatus,
916
+ aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
917
+ };
918
+ });
919
+ }
690
920
  }
691
921
  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 },
@@ -10,6 +10,12 @@ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
10
10
  */
11
11
  const schema = new mongoose.Schema({
12
12
  _id: String,
13
+ aggregateReservation: mongoose.SchemaTypes.Mixed,
14
+ alternateName: String,
15
+ logo: String,
16
+ name: String,
17
+ settings: mongoose.SchemaTypes.Mixed,
18
+ subscription: mongoose.SchemaTypes.Mixed,
13
19
  typeOf: {
14
20
  type: String,
15
21
  required: true
@@ -19,7 +25,7 @@ const schema = new mongoose.Schema({
19
25
  id: true,
20
26
  read: 'primaryPreferred',
21
27
  writeConcern: writeConcern,
22
- strict: false,
28
+ strict: true,
23
29
  useNestedStrict: true,
24
30
  timestamps: {
25
31
  createdAt: 'createdAt',
@@ -10,7 +10,6 @@ export declare class MongoRepository {
10
10
  findById(conditions: {
11
11
  id: string;
12
12
  }, projection?: any): Promise<factory.project.IProject>;
13
- count(params: factory.project.ISearchConditions): Promise<number>;
14
13
  /**
15
14
  * プロジェクト検索
16
15
  */
@@ -24,6 +23,9 @@ export declare class MongoRepository {
24
23
  settings?: {
25
24
  sendgridApiKey?: string;
26
25
  };
26
+ subscription?: {
27
+ useEventServiceAsProduct?: boolean;
28
+ };
27
29
  }): Promise<void>;
28
30
  updateAggregateReservation(params: {
29
31
  id: string;
@@ -32,4 +34,5 @@ export declare class MongoRepository {
32
34
  deleteById(params: {
33
35
  id: string;
34
36
  }): Promise<void>;
37
+ getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
35
38
  }
@@ -61,14 +61,6 @@ class MongoRepository {
61
61
  return doc.toObject();
62
62
  });
63
63
  }
64
- count(params) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
67
- return this.projectModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
68
- .setOptions({ maxTimeMS: 10000 })
69
- .exec();
70
- });
71
- }
72
64
  /**
73
65
  * プロジェクト検索
74
66
  */
@@ -98,12 +90,14 @@ class MongoRepository {
98
90
  });
99
91
  }
100
92
  findByIdAndIUpdate(params) {
101
- var _a;
93
+ var _a, _b;
102
94
  return __awaiter(this, void 0, void 0, function* () {
103
- yield this.projectModel.findOneAndUpdate({ _id: params.id }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date() }, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
95
+ yield this.projectModel.findOneAndUpdate({ _id: params.id }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date() }, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
104
96
  ? { alternateName: params.alternateName }
105
97
  : undefined), (typeof params.name === 'string' && params.name.length > 0) ? { name: params.name } : undefined), (typeof params.logo === 'string' && params.logo.length > 0) ? { logo: params.logo } : undefined), (typeof ((_a = params.settings) === null || _a === void 0 ? void 0 : _a.sendgridApiKey) === 'string')
106
98
  ? { 'settings.sendgridApiKey': params.settings.sendgridApiKey }
99
+ : undefined), (typeof ((_b = params.subscription) === null || _b === void 0 ? void 0 : _b.useEventServiceAsProduct) === 'boolean')
100
+ ? { 'subscription.useEventServiceAsProduct': params.subscription.useEventServiceAsProduct }
107
101
  : undefined), {
108
102
  // ↓customerUserPoolは廃止
109
103
  $unset: {
@@ -131,5 +125,10 @@ class MongoRepository {
131
125
  .exec();
132
126
  });
133
127
  }
128
+ getCursor(conditions, projection) {
129
+ return this.projectModel.find(conditions, projection)
130
+ .sort({ _id: factory.sortType.Ascending })
131
+ .cursor();
132
+ }
134
133
  }
135
134
  exports.MongoRepository = MongoRepository;
@@ -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.26"
123
+ "version": "20.2.0-alpha.28"
124
124
  }
@@ -1,77 +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 productRepo = new chevre.repository.Product(mongoose.connection);
15
-
16
- const cursor = productRepo.getCursor(
17
- {
18
- // 'project.id': { $eq: project.id },
19
- 'project.id': { $ne: EXCLUDED_PROJECT_ID },
20
- typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
21
- },
22
- {
23
- // _id: 1,
24
- }
25
- );
26
- console.log('products found');
27
-
28
- let i = 0;
29
- let updateCount = 0;
30
- // tslint:disable-next-line:max-func-body-length
31
- await cursor.eachAsync(async (doc) => {
32
- i += 1;
33
- const paymentService: chevre.factory.service.paymentService.IService = doc.toObject();
34
-
35
- const hasPaymentUrlExpiresInseconds = paymentService.provider?.some((provider) => {
36
- return typeof (<any>provider).credentials?.paymentUrlExpiresInSeconds === 'number';
37
- });
38
-
39
- if (!hasPaymentUrlExpiresInseconds) {
40
- console.log(
41
- 'no expiresInSeconds', paymentService.project.id, paymentService.id, paymentService.productID, i);
42
-
43
- return;
44
- }
45
-
46
- const alreadyMigrated = paymentService.provider?.filter((provider) => {
47
- return typeof (<any>provider).credentials?.paymentUrlExpiresInSeconds === 'number';
48
- })
49
- .every((provider) => {
50
- return typeof provider.credentials?.paymentUrl?.expiresInSeconds === 'number';
51
- });
52
-
53
- if (alreadyMigrated) {
54
- console.log(
55
- 'already exist...', paymentService.project.id, paymentService.id, paymentService.productID, i);
56
- } else {
57
- console.log(
58
- 'updating product...', paymentService.project.id, paymentService.id, paymentService.productID, i);
59
- // await eventRepo.updatePartiallyById({
60
- // id: event.id,
61
- // attributes: <any>{
62
- // typeOf: event.typeOf,
63
- // 'offers.itemOffered.availableChannel': newAvailableChannel
64
- // }
65
- // });
66
- updateCount += 1;
67
- console.log(
68
- 'updated...', paymentService.project.id, paymentService.id, paymentService.productID, i);
69
- }
70
- });
71
- console.log(i, 'products checked');
72
- console.log(updateCount, 'products updated');
73
- }
74
-
75
- main()
76
- .then()
77
- .catch(console.error);