@chevre/domain 24.0.0-alpha.16 → 24.0.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/repo/action/acceptCOAOffer.d.ts +23 -0
- package/lib/chevre/repo/action/acceptCOAOffer.js +64 -0
- package/lib/chevre/repo/action/acceptPay.d.ts +8 -0
- package/lib/chevre/repo/action/acceptPay.js +13 -0
- package/lib/chevre/repo/action/actionProcess.d.ts +115 -0
- package/lib/chevre/repo/action/actionProcess.js +293 -0
- package/lib/chevre/repo/action/authorizeOffer.d.ts +21 -0
- package/lib/chevre/repo/action/authorizeOffer.js +85 -0
- package/lib/chevre/repo/action/checkMovieTicket.d.ts +55 -0
- package/lib/chevre/repo/action/checkMovieTicket.js +145 -0
- package/lib/chevre/repo/action/checkThing.d.ts +8 -0
- package/lib/chevre/repo/action/checkThing.js +13 -0
- package/lib/chevre/repo/action.d.ts +9 -249
- package/lib/chevre/repo/action.js +308 -708
- package/lib/chevre/repo/aggregateAction.d.ts +102 -0
- package/lib/chevre/repo/aggregateAction.js +379 -0
- package/lib/chevre/repository.d.ts +27 -0
- package/lib/chevre/repository.js +60 -2
- package/lib/chevre/service/aggregation/system.d.ts +10 -10
- package/lib/chevre/service/aggregation/system.js +9 -9
- package/lib/chevre/service/assetTransaction/pay/check.d.ts +5 -4
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +5 -2
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +3 -3
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +14 -3
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +4 -2
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +21 -13
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +17 -8
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +2 -2
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +2 -2
- package/lib/chevre/service/payment/any/findAcceptAction.js +2 -2
- package/lib/chevre/service/payment/any/findCheckAction.d.ts +7 -6
- package/lib/chevre/service/payment/any/findCheckAction.js +2 -2
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +2 -0
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +3 -3
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +3 -3
- package/lib/chevre/service/task/acceptCOAOffer.js +5 -2
- package/lib/chevre/service/task/checkMovieTicket.js +3 -3
- package/lib/chevre/service/task/checkResource.js +2 -2
- package/lib/chevre/service/task/publishPaymentUrl.js +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
interface IAggregationByStatus {
|
|
4
|
+
actionCount: number;
|
|
5
|
+
avgDuration: number;
|
|
6
|
+
maxDuration: number;
|
|
7
|
+
minDuration: number;
|
|
8
|
+
percentilesDuration: {
|
|
9
|
+
name: string;
|
|
10
|
+
value: number;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
interface IStatus {
|
|
14
|
+
status: factory.actionStatusType;
|
|
15
|
+
aggregation: IAggregationByStatus;
|
|
16
|
+
}
|
|
17
|
+
interface IAggregateAction {
|
|
18
|
+
statuses: IStatus[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* アクション集計リポジトリ
|
|
22
|
+
*/
|
|
23
|
+
export declare class AggregateActionRepo {
|
|
24
|
+
private readonly actionModel;
|
|
25
|
+
constructor(connection: Connection);
|
|
26
|
+
/**
|
|
27
|
+
* イベントと入場ゲート指定で予約使用アクションを集計する
|
|
28
|
+
* discontinue(2024-12-26~)
|
|
29
|
+
*/
|
|
30
|
+
aggregateAuthorizeEventServiceOfferAction(params: {
|
|
31
|
+
project?: {
|
|
32
|
+
id?: {
|
|
33
|
+
$ne?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
startFrom: Date;
|
|
37
|
+
startThrough: Date;
|
|
38
|
+
typeOf: factory.actionType;
|
|
39
|
+
}): Promise<IAggregateAction>;
|
|
40
|
+
aggregateAuthorizePaymentAction(params: {
|
|
41
|
+
project?: {
|
|
42
|
+
id?: {
|
|
43
|
+
$ne?: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
startFrom: Date;
|
|
47
|
+
startThrough: Date;
|
|
48
|
+
typeOf: factory.actionType;
|
|
49
|
+
}): Promise<IAggregateAction>;
|
|
50
|
+
aggregateAuthorizeOrderAction(params: {
|
|
51
|
+
project?: {
|
|
52
|
+
id?: {
|
|
53
|
+
$ne?: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
startFrom: Date;
|
|
57
|
+
startThrough: Date;
|
|
58
|
+
typeOf: factory.actionType;
|
|
59
|
+
}): Promise<IAggregateAction>;
|
|
60
|
+
aggregateCancelReservationAction(params: {
|
|
61
|
+
project?: {
|
|
62
|
+
id?: {
|
|
63
|
+
$ne?: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
startFrom: Date;
|
|
67
|
+
startThrough: Date;
|
|
68
|
+
}): Promise<IAggregateAction>;
|
|
69
|
+
/**
|
|
70
|
+
* アクションタイプによる汎用的な集計
|
|
71
|
+
*/
|
|
72
|
+
aggregateByTypeOf(params: {
|
|
73
|
+
project?: {
|
|
74
|
+
id?: {
|
|
75
|
+
$ne?: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
startFrom: Date;
|
|
79
|
+
startThrough: Date;
|
|
80
|
+
typeOf: factory.actionType;
|
|
81
|
+
}): Promise<IAggregateAction>;
|
|
82
|
+
aggregateCheckMovieTicketAction(params: {
|
|
83
|
+
project?: {
|
|
84
|
+
id?: {
|
|
85
|
+
$ne?: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
startFrom: Date;
|
|
89
|
+
startThrough: Date;
|
|
90
|
+
}): Promise<IAggregateAction>;
|
|
91
|
+
aggregatePayMovieTicketAction(params: {
|
|
92
|
+
project?: {
|
|
93
|
+
id?: {
|
|
94
|
+
$ne?: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
startFrom: Date;
|
|
98
|
+
startThrough: Date;
|
|
99
|
+
}): Promise<IAggregateAction>;
|
|
100
|
+
private agggregateByStatus;
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.AggregateActionRepo = void 0;
|
|
27
|
+
const factory = __importStar(require("../factory"));
|
|
28
|
+
// import { MONGO_MAX_TIME_MS } from '../../settings';
|
|
29
|
+
const action_1 = require("./mongoose/schemas/action");
|
|
30
|
+
/**
|
|
31
|
+
* アクション集計リポジトリ
|
|
32
|
+
*/
|
|
33
|
+
class AggregateActionRepo {
|
|
34
|
+
actionModel;
|
|
35
|
+
// private readonly actionRecipeModel: IActionRecipeModel;
|
|
36
|
+
constructor(connection) {
|
|
37
|
+
this.actionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
|
|
38
|
+
// this.actionRecipeModel = connection.model(recipeModelName, createRecipeSchema());
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* イベントと入場ゲート指定で予約使用アクションを集計する
|
|
42
|
+
* discontinue(2024-12-26~)
|
|
43
|
+
*/
|
|
44
|
+
// public async countUseActionsByEntranceGate(params: {
|
|
45
|
+
// event: { id: string };
|
|
46
|
+
// entranceGateIdentifier: string;
|
|
47
|
+
// }): Promise<IUseActionCountByOffer[]> {
|
|
48
|
+
// return this.actionModel.aggregate([
|
|
49
|
+
// {
|
|
50
|
+
// $match: {
|
|
51
|
+
// actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
52
|
+
// }
|
|
53
|
+
// },
|
|
54
|
+
// {
|
|
55
|
+
// $match: {
|
|
56
|
+
// typeOf: { $eq: factory.actionType.UseAction }
|
|
57
|
+
// }
|
|
58
|
+
// },
|
|
59
|
+
// {
|
|
60
|
+
// $match: {
|
|
61
|
+
// 'object.typeOf': {
|
|
62
|
+
// $exists: true,
|
|
63
|
+
// $eq: factory.reservationType.EventReservation
|
|
64
|
+
// }
|
|
65
|
+
// }
|
|
66
|
+
// },
|
|
67
|
+
// {
|
|
68
|
+
// $match: {
|
|
69
|
+
// 'object.reservationFor.id': {
|
|
70
|
+
// $exists: true,
|
|
71
|
+
// $eq: params.event.id
|
|
72
|
+
// }
|
|
73
|
+
// }
|
|
74
|
+
// },
|
|
75
|
+
// {
|
|
76
|
+
// $match: {
|
|
77
|
+
// 'location.identifier': {
|
|
78
|
+
// $exists: true,
|
|
79
|
+
// $eq: params.entranceGateIdentifier
|
|
80
|
+
// }
|
|
81
|
+
// }
|
|
82
|
+
// },
|
|
83
|
+
// {
|
|
84
|
+
// $group: {
|
|
85
|
+
// _id: '$object.id',
|
|
86
|
+
// object: { $first: '$object' }
|
|
87
|
+
// }
|
|
88
|
+
// },
|
|
89
|
+
// {
|
|
90
|
+
// $group: {
|
|
91
|
+
// _id: '$object.reservedTicket.ticketType.id',
|
|
92
|
+
// useActionCount: {
|
|
93
|
+
// $sum: 1
|
|
94
|
+
// }
|
|
95
|
+
// }
|
|
96
|
+
// }
|
|
97
|
+
// ])
|
|
98
|
+
// .exec();
|
|
99
|
+
// }
|
|
100
|
+
async aggregateAuthorizeEventServiceOfferAction(params) {
|
|
101
|
+
const statuses = await Promise.all([
|
|
102
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
103
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
104
|
+
factory.actionStatusType.FailedActionStatus
|
|
105
|
+
].map(async (actionStatus) => {
|
|
106
|
+
const matchConditions = {
|
|
107
|
+
startDate: {
|
|
108
|
+
$gte: params.startFrom,
|
|
109
|
+
$lte: params.startThrough
|
|
110
|
+
},
|
|
111
|
+
typeOf: { $eq: params.typeOf },
|
|
112
|
+
actionStatus: { $eq: actionStatus },
|
|
113
|
+
'object.typeOf': {
|
|
114
|
+
$exists: true,
|
|
115
|
+
$eq: factory.action.authorize.offer.eventService.ObjectType.SeatReservation
|
|
116
|
+
},
|
|
117
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
118
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
119
|
+
: undefined
|
|
120
|
+
};
|
|
121
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
122
|
+
}));
|
|
123
|
+
return { statuses };
|
|
124
|
+
}
|
|
125
|
+
async aggregateAuthorizePaymentAction(params) {
|
|
126
|
+
const statuses = await Promise.all([
|
|
127
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
128
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
129
|
+
factory.actionStatusType.FailedActionStatus
|
|
130
|
+
].map(async (actionStatus) => {
|
|
131
|
+
const matchConditions = {
|
|
132
|
+
startDate: {
|
|
133
|
+
$gte: params.startFrom,
|
|
134
|
+
$lte: params.startThrough
|
|
135
|
+
},
|
|
136
|
+
typeOf: { $eq: params.typeOf },
|
|
137
|
+
actionStatus: { $eq: actionStatus },
|
|
138
|
+
'object.typeOf': {
|
|
139
|
+
$exists: true,
|
|
140
|
+
$eq: factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
141
|
+
},
|
|
142
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
143
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
144
|
+
: undefined
|
|
145
|
+
};
|
|
146
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
147
|
+
}));
|
|
148
|
+
return { statuses };
|
|
149
|
+
}
|
|
150
|
+
async aggregateAuthorizeOrderAction(params) {
|
|
151
|
+
const statuses = await Promise.all([
|
|
152
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
153
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
154
|
+
factory.actionStatusType.FailedActionStatus
|
|
155
|
+
].map(async (actionStatus) => {
|
|
156
|
+
const matchConditions = {
|
|
157
|
+
startDate: {
|
|
158
|
+
$gte: params.startFrom,
|
|
159
|
+
$lte: params.startThrough
|
|
160
|
+
},
|
|
161
|
+
typeOf: { $eq: params.typeOf },
|
|
162
|
+
actionStatus: { $eq: actionStatus },
|
|
163
|
+
'object.typeOf': {
|
|
164
|
+
$exists: true,
|
|
165
|
+
$eq: factory.order.OrderType.Order
|
|
166
|
+
},
|
|
167
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
168
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
169
|
+
: undefined
|
|
170
|
+
};
|
|
171
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
172
|
+
}));
|
|
173
|
+
return { statuses };
|
|
174
|
+
}
|
|
175
|
+
async aggregateCancelReservationAction(params) {
|
|
176
|
+
const statuses = await Promise.all([
|
|
177
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
178
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
179
|
+
factory.actionStatusType.FailedActionStatus
|
|
180
|
+
].map(async (actionStatus) => {
|
|
181
|
+
const matchConditions = {
|
|
182
|
+
startDate: {
|
|
183
|
+
$gte: params.startFrom,
|
|
184
|
+
$lte: params.startThrough
|
|
185
|
+
},
|
|
186
|
+
typeOf: { $eq: factory.actionType.CancelAction },
|
|
187
|
+
actionStatus: { $eq: actionStatus },
|
|
188
|
+
'object.typeOf': {
|
|
189
|
+
$exists: true,
|
|
190
|
+
$in: [
|
|
191
|
+
factory.reservationType.BusReservation,
|
|
192
|
+
factory.reservationType.EventReservation,
|
|
193
|
+
factory.reservationType.ReservationPackage
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
197
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
198
|
+
: undefined
|
|
199
|
+
};
|
|
200
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
201
|
+
}));
|
|
202
|
+
return { statuses };
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* アクションタイプによる汎用的な集計
|
|
206
|
+
*/
|
|
207
|
+
async aggregateByTypeOf(params) {
|
|
208
|
+
const statuses = await Promise.all([
|
|
209
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
210
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
211
|
+
factory.actionStatusType.FailedActionStatus
|
|
212
|
+
].map(async (actionStatus) => {
|
|
213
|
+
const matchConditions = {
|
|
214
|
+
startDate: {
|
|
215
|
+
$gte: params.startFrom,
|
|
216
|
+
$lte: params.startThrough
|
|
217
|
+
},
|
|
218
|
+
typeOf: { $eq: params.typeOf },
|
|
219
|
+
actionStatus: { $eq: actionStatus },
|
|
220
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
221
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
222
|
+
: undefined
|
|
223
|
+
};
|
|
224
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
225
|
+
}));
|
|
226
|
+
return { statuses };
|
|
227
|
+
}
|
|
228
|
+
async aggregateCheckMovieTicketAction(params) {
|
|
229
|
+
const statuses = await Promise.all([
|
|
230
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
231
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
232
|
+
factory.actionStatusType.FailedActionStatus
|
|
233
|
+
].map(async (actionStatus) => {
|
|
234
|
+
const matchConditions = {
|
|
235
|
+
startDate: {
|
|
236
|
+
$gte: params.startFrom,
|
|
237
|
+
$lte: params.startThrough
|
|
238
|
+
},
|
|
239
|
+
typeOf: { $eq: factory.actionType.CheckAction },
|
|
240
|
+
'object.typeOf': {
|
|
241
|
+
$exists: true,
|
|
242
|
+
$eq: factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
243
|
+
},
|
|
244
|
+
actionStatus: { $eq: actionStatus },
|
|
245
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
246
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
247
|
+
: undefined
|
|
248
|
+
};
|
|
249
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
250
|
+
}));
|
|
251
|
+
return { statuses };
|
|
252
|
+
}
|
|
253
|
+
async aggregatePayMovieTicketAction(params) {
|
|
254
|
+
const statuses = await Promise.all([
|
|
255
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
256
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
257
|
+
factory.actionStatusType.FailedActionStatus
|
|
258
|
+
].map(async (actionStatus) => {
|
|
259
|
+
const matchConditions = {
|
|
260
|
+
startDate: {
|
|
261
|
+
$gte: params.startFrom,
|
|
262
|
+
$lte: params.startThrough
|
|
263
|
+
},
|
|
264
|
+
typeOf: { $eq: factory.actionType.PayAction },
|
|
265
|
+
'object.typeOf': {
|
|
266
|
+
$exists: true,
|
|
267
|
+
$eq: factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
268
|
+
},
|
|
269
|
+
actionStatus: { $eq: actionStatus },
|
|
270
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
271
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
272
|
+
: undefined
|
|
273
|
+
};
|
|
274
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
275
|
+
}));
|
|
276
|
+
return { statuses };
|
|
277
|
+
}
|
|
278
|
+
async agggregateByStatus(params) {
|
|
279
|
+
const aggregations = await this.actionModel.aggregate([
|
|
280
|
+
{ $match: params.matchConditions },
|
|
281
|
+
{
|
|
282
|
+
$project: {
|
|
283
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
284
|
+
actionStatus: '$actionStatus',
|
|
285
|
+
startDate: '$startDate',
|
|
286
|
+
endDate: '$endDate',
|
|
287
|
+
typeOf: '$typeOf'
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
$group: {
|
|
292
|
+
_id: '$typeOf',
|
|
293
|
+
actionCount: { $sum: 1 },
|
|
294
|
+
maxDuration: { $max: '$duration' },
|
|
295
|
+
minDuration: { $min: '$duration' },
|
|
296
|
+
avgDuration: { $avg: '$duration' }
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
$project: {
|
|
301
|
+
_id: 0,
|
|
302
|
+
actionCount: '$actionCount',
|
|
303
|
+
avgDuration: '$avgDuration',
|
|
304
|
+
maxDuration: '$maxDuration',
|
|
305
|
+
minDuration: '$minDuration'
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
])
|
|
309
|
+
.exec();
|
|
310
|
+
const percents = [50, 95, 99];
|
|
311
|
+
if (aggregations.length === 0) {
|
|
312
|
+
return {
|
|
313
|
+
status: params.actionStatus,
|
|
314
|
+
aggregation: {
|
|
315
|
+
actionCount: 0,
|
|
316
|
+
avgDuration: 0,
|
|
317
|
+
maxDuration: 0,
|
|
318
|
+
minDuration: 0,
|
|
319
|
+
percentilesDuration: percents.map((percent) => {
|
|
320
|
+
return {
|
|
321
|
+
name: String(percent),
|
|
322
|
+
value: 0
|
|
323
|
+
};
|
|
324
|
+
})
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
329
|
+
return {
|
|
330
|
+
percentile,
|
|
331
|
+
rank: Math.floor(aggregations[0].actionCount * percentile / 100)
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
const aggregations2 = await this.actionModel.aggregate([
|
|
335
|
+
{
|
|
336
|
+
$match: params.matchConditions
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
$project: {
|
|
340
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
341
|
+
actionStatus: '$actionStatus',
|
|
342
|
+
startDate: '$startDate',
|
|
343
|
+
endDate: '$endDate',
|
|
344
|
+
typeOf: '$typeOf'
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{ $sort: { duration: 1 } },
|
|
348
|
+
{
|
|
349
|
+
$group: {
|
|
350
|
+
_id: '$typeOf',
|
|
351
|
+
durations: { $push: '$duration' }
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
$project: {
|
|
356
|
+
_id: 0,
|
|
357
|
+
avgSmallDuration: '$avgSmallDuration',
|
|
358
|
+
avgMediumDuration: '$avgMediumDuration',
|
|
359
|
+
avgLargeDuration: '$avgLargeDuration',
|
|
360
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
361
|
+
return {
|
|
362
|
+
name: String(rank.percentile),
|
|
363
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
364
|
+
};
|
|
365
|
+
})
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
])
|
|
369
|
+
.exec();
|
|
370
|
+
return {
|
|
371
|
+
status: params.actionStatus,
|
|
372
|
+
aggregation: {
|
|
373
|
+
...aggregations[0],
|
|
374
|
+
...aggregations2[0]
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
exports.AggregateActionRepo = AggregateActionRepo;
|
|
@@ -8,8 +8,13 @@ import type { AccountingReportRepo } from './repo/accountingReport';
|
|
|
8
8
|
import type { AccountTitleRepo } from './repo/accountTitle';
|
|
9
9
|
import type { AccountTransactionRepo } from './repo/accountTransaction';
|
|
10
10
|
import type { ActionRepo } from './repo/action';
|
|
11
|
+
import type { AcceptCOAOfferActionRepo } from './repo/action/acceptCOAOffer';
|
|
12
|
+
import type { AuthorizeOfferActionRepo } from './repo/action/authorizeOffer';
|
|
13
|
+
import type { CheckMovieTicketActionRepo } from './repo/action/checkMovieTicket';
|
|
14
|
+
import type { CheckThingActionRepo } from './repo/action/checkThing';
|
|
11
15
|
import type { AdditionalPropertyRepo } from './repo/additionalProperty';
|
|
12
16
|
import type { AdvanceBookingRequirementRepo } from './repo/advanceBookingRequirement';
|
|
17
|
+
import type { AggregateActionRepo } from './repo/aggregateAction';
|
|
13
18
|
import type { AggregateOfferRepo } from './repo/aggregateOffer';
|
|
14
19
|
import type { AggregateOrderRepo } from './repo/aggregateOrder';
|
|
15
20
|
import type { AggregateReservationRepo } from './repo/aggregateReservation';
|
|
@@ -123,6 +128,24 @@ export type Action = ActionRepo;
|
|
|
123
128
|
export declare namespace Action {
|
|
124
129
|
function createInstance(...params: ConstructorParameters<typeof ActionRepo>): Promise<ActionRepo>;
|
|
125
130
|
}
|
|
131
|
+
export declare namespace action {
|
|
132
|
+
type AcceptCOAOffer = AcceptCOAOfferActionRepo;
|
|
133
|
+
namespace AcceptCOAOffer {
|
|
134
|
+
function createInstance(...params: ConstructorParameters<typeof AcceptCOAOfferActionRepo>): Promise<AcceptCOAOfferActionRepo>;
|
|
135
|
+
}
|
|
136
|
+
type AuthorizeOffer = AuthorizeOfferActionRepo;
|
|
137
|
+
namespace AuthorizeOffer {
|
|
138
|
+
function createInstance(...params: ConstructorParameters<typeof AuthorizeOfferActionRepo>): Promise<AuthorizeOfferActionRepo>;
|
|
139
|
+
}
|
|
140
|
+
type CheckMovieTicket = CheckMovieTicketActionRepo;
|
|
141
|
+
namespace CheckMovieTicket {
|
|
142
|
+
function createInstance(...params: ConstructorParameters<typeof CheckMovieTicketActionRepo>): Promise<CheckMovieTicketActionRepo>;
|
|
143
|
+
}
|
|
144
|
+
type CheckThing = CheckThingActionRepo;
|
|
145
|
+
namespace CheckThing {
|
|
146
|
+
function createInstance(...params: ConstructorParameters<typeof CheckThingActionRepo>): Promise<CheckThingActionRepo>;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
126
149
|
export type AdditionalProperty = AdditionalPropertyRepo;
|
|
127
150
|
export declare namespace AdditionalProperty {
|
|
128
151
|
function createInstance(...params: ConstructorParameters<typeof AdditionalPropertyRepo>): Promise<AdditionalPropertyRepo>;
|
|
@@ -131,6 +154,10 @@ export type AdvanceBookingRequirement = AdvanceBookingRequirementRepo;
|
|
|
131
154
|
export declare namespace AdvanceBookingRequirement {
|
|
132
155
|
function createInstance(...params: ConstructorParameters<typeof AdvanceBookingRequirementRepo>): Promise<AdvanceBookingRequirementRepo>;
|
|
133
156
|
}
|
|
157
|
+
export type AggregateAction = AggregateActionRepo;
|
|
158
|
+
export declare namespace AggregateAction {
|
|
159
|
+
function createInstance(...params: ConstructorParameters<typeof AggregateActionRepo>): Promise<AggregateActionRepo>;
|
|
160
|
+
}
|
|
134
161
|
export type AggregateOffer = AggregateOfferRepo;
|
|
135
162
|
export declare namespace AggregateOffer {
|
|
136
163
|
function createInstance(...params: ConstructorParameters<typeof AggregateOfferRepo>): Promise<AggregateOfferRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = exports.Person = exports.paymentMethod = void 0;
|
|
26
|
+
exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateAction = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedPaymentMethod = exports.AcceptedOffer = void 0;
|
|
27
|
+
exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = void 0;
|
|
28
28
|
var AcceptedOffer;
|
|
29
29
|
(function (AcceptedOffer) {
|
|
30
30
|
let repo;
|
|
@@ -102,6 +102,53 @@ var Action;
|
|
|
102
102
|
}
|
|
103
103
|
Action.createInstance = createInstance;
|
|
104
104
|
})(Action || (exports.Action = Action = {}));
|
|
105
|
+
var action;
|
|
106
|
+
(function (action) {
|
|
107
|
+
let AcceptCOAOffer;
|
|
108
|
+
(function (AcceptCOAOffer) {
|
|
109
|
+
let repo;
|
|
110
|
+
async function createInstance(...params) {
|
|
111
|
+
if (repo === undefined) {
|
|
112
|
+
repo = (await Promise.resolve().then(() => __importStar(require('./repo/action/acceptCOAOffer')))).AcceptCOAOfferActionRepo;
|
|
113
|
+
}
|
|
114
|
+
return new repo(...params);
|
|
115
|
+
}
|
|
116
|
+
AcceptCOAOffer.createInstance = createInstance;
|
|
117
|
+
})(AcceptCOAOffer = action.AcceptCOAOffer || (action.AcceptCOAOffer = {}));
|
|
118
|
+
let AuthorizeOffer;
|
|
119
|
+
(function (AuthorizeOffer) {
|
|
120
|
+
let repo;
|
|
121
|
+
async function createInstance(...params) {
|
|
122
|
+
if (repo === undefined) {
|
|
123
|
+
repo = (await Promise.resolve().then(() => __importStar(require('./repo/action/authorizeOffer')))).AuthorizeOfferActionRepo;
|
|
124
|
+
}
|
|
125
|
+
return new repo(...params);
|
|
126
|
+
}
|
|
127
|
+
AuthorizeOffer.createInstance = createInstance;
|
|
128
|
+
})(AuthorizeOffer = action.AuthorizeOffer || (action.AuthorizeOffer = {}));
|
|
129
|
+
let CheckMovieTicket;
|
|
130
|
+
(function (CheckMovieTicket) {
|
|
131
|
+
let repo;
|
|
132
|
+
async function createInstance(...params) {
|
|
133
|
+
if (repo === undefined) {
|
|
134
|
+
repo = (await Promise.resolve().then(() => __importStar(require('./repo/action/checkMovieTicket')))).CheckMovieTicketActionRepo;
|
|
135
|
+
}
|
|
136
|
+
return new repo(...params);
|
|
137
|
+
}
|
|
138
|
+
CheckMovieTicket.createInstance = createInstance;
|
|
139
|
+
})(CheckMovieTicket = action.CheckMovieTicket || (action.CheckMovieTicket = {}));
|
|
140
|
+
let CheckThing;
|
|
141
|
+
(function (CheckThing) {
|
|
142
|
+
let repo;
|
|
143
|
+
async function createInstance(...params) {
|
|
144
|
+
if (repo === undefined) {
|
|
145
|
+
repo = (await Promise.resolve().then(() => __importStar(require('./repo/action/checkThing')))).CheckThingActionRepo;
|
|
146
|
+
}
|
|
147
|
+
return new repo(...params);
|
|
148
|
+
}
|
|
149
|
+
CheckThing.createInstance = createInstance;
|
|
150
|
+
})(CheckThing = action.CheckThing || (action.CheckThing = {}));
|
|
151
|
+
})(action || (exports.action = action = {}));
|
|
105
152
|
var AdditionalProperty;
|
|
106
153
|
(function (AdditionalProperty) {
|
|
107
154
|
let repo;
|
|
@@ -124,6 +171,17 @@ var AdvanceBookingRequirement;
|
|
|
124
171
|
}
|
|
125
172
|
AdvanceBookingRequirement.createInstance = createInstance;
|
|
126
173
|
})(AdvanceBookingRequirement || (exports.AdvanceBookingRequirement = AdvanceBookingRequirement = {}));
|
|
174
|
+
var AggregateAction;
|
|
175
|
+
(function (AggregateAction) {
|
|
176
|
+
let repo;
|
|
177
|
+
async function createInstance(...params) {
|
|
178
|
+
if (repo === undefined) {
|
|
179
|
+
repo = (await Promise.resolve().then(() => __importStar(require('./repo/aggregateAction')))).AggregateActionRepo;
|
|
180
|
+
}
|
|
181
|
+
return new repo(...params);
|
|
182
|
+
}
|
|
183
|
+
AggregateAction.createInstance = createInstance;
|
|
184
|
+
})(AggregateAction || (exports.AggregateAction = AggregateAction = {}));
|
|
127
185
|
var AggregateOffer;
|
|
128
186
|
(function (AggregateOffer) {
|
|
129
187
|
let repo;
|