@chevre/domain 21.2.0-alpha.101 → 21.2.0-alpha.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/aggregation/aggregateSystem.ts +24 -0
- package/lib/chevre/repo/action.d.ts +4 -1
- package/lib/chevre/repo/action.js +4 -1
- package/lib/chevre/repo/aggregation.d.ts +2 -0
- package/lib/chevre/repo/aggregation.js +2 -0
- package/lib/chevre/service/aggregation/system.d.ts +29 -1
- package/lib/chevre/service/aggregation/system.js +76 -2
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/offer.js +4 -1
- package/package.json +1 -1
|
@@ -22,6 +22,30 @@ async function main() {
|
|
|
22
22
|
|
|
23
23
|
let result: { aggregationCount: number; aggregateDuration: string };
|
|
24
24
|
|
|
25
|
+
result = await chevre.service.aggregation.system.aggregateReserveAction({
|
|
26
|
+
aggregateDurationUnit: 'hours',
|
|
27
|
+
// aggregateDurationUnit: 'days',
|
|
28
|
+
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
29
|
+
// aggregationCount: AGGREGATE_DAYS,
|
|
30
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
31
|
+
})({
|
|
32
|
+
agregation: aggregationRepo,
|
|
33
|
+
action: actionRepo
|
|
34
|
+
});
|
|
35
|
+
console.log('aggregateReserveAction processed.', result);
|
|
36
|
+
|
|
37
|
+
result = await chevre.service.aggregation.system.aggregateOrderAction({
|
|
38
|
+
aggregateDurationUnit: 'hours',
|
|
39
|
+
// aggregateDurationUnit: 'days',
|
|
40
|
+
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
41
|
+
// aggregationCount: AGGREGATE_DAYS,
|
|
42
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
43
|
+
})({
|
|
44
|
+
agregation: aggregationRepo,
|
|
45
|
+
action: actionRepo
|
|
46
|
+
});
|
|
47
|
+
console.log('aggregateReserveAction processed.', result);
|
|
48
|
+
|
|
25
49
|
result = await chevre.service.aggregation.system.aggregatePlaceOrder({
|
|
26
50
|
aggregateDurationUnit: 'hours',
|
|
27
51
|
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
@@ -180,7 +180,10 @@ export declare class MongoRepository {
|
|
|
180
180
|
startThrough: Date;
|
|
181
181
|
typeOf: factory.actionType;
|
|
182
182
|
}): Promise<IAggregateAction>;
|
|
183
|
-
|
|
183
|
+
/**
|
|
184
|
+
* アクションタイプによる汎用的な集計
|
|
185
|
+
*/
|
|
186
|
+
aggregateByTypeOf(params: {
|
|
184
187
|
project?: {
|
|
185
188
|
id?: {
|
|
186
189
|
$ne?: string;
|
|
@@ -801,7 +801,10 @@ class MongoRepository {
|
|
|
801
801
|
return { statuses };
|
|
802
802
|
});
|
|
803
803
|
}
|
|
804
|
-
|
|
804
|
+
/**
|
|
805
|
+
* アクションタイプによる汎用的な集計
|
|
806
|
+
*/
|
|
807
|
+
aggregateByTypeOf(params) {
|
|
805
808
|
return __awaiter(this, void 0, void 0, function* () {
|
|
806
809
|
const statuses = yield Promise.all([
|
|
807
810
|
factory.actionStatusType.CompletedActionStatus,
|
|
@@ -6,10 +6,12 @@ export declare enum AggregationType {
|
|
|
6
6
|
AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
|
|
7
7
|
AggregateCheckMovieTicketAction = "AggregateCheckMovieTicketAction",
|
|
8
8
|
AggregateEvent = "AggregateEvent",
|
|
9
|
+
AggregateOrderAction = "AggregateOrderAction",
|
|
9
10
|
AggregatePay = "AggregatePay",
|
|
10
11
|
AggregatePayMovieTicketAction = "AggregatePayMovieTicketAction",
|
|
11
12
|
AggregatePlaceOrder = "AggregatePlaceOrder",
|
|
12
13
|
AggregateReserve = "AggregateReserve",
|
|
14
|
+
AggregateReserveAction = "AggregateReserveAction",
|
|
13
15
|
AggregateTask = "AggregateTask",
|
|
14
16
|
AggregateUseAction = "AggregateUseAction"
|
|
15
17
|
}
|
|
@@ -29,10 +29,12 @@ var AggregationType;
|
|
|
29
29
|
AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
|
|
30
30
|
AggregationType["AggregateCheckMovieTicketAction"] = "AggregateCheckMovieTicketAction";
|
|
31
31
|
AggregationType["AggregateEvent"] = "AggregateEvent";
|
|
32
|
+
AggregationType["AggregateOrderAction"] = "AggregateOrderAction";
|
|
32
33
|
AggregationType["AggregatePay"] = "AggregatePay";
|
|
33
34
|
AggregationType["AggregatePayMovieTicketAction"] = "AggregatePayMovieTicketAction";
|
|
34
35
|
AggregationType["AggregatePlaceOrder"] = "AggregatePlaceOrder";
|
|
35
36
|
AggregationType["AggregateReserve"] = "AggregateReserve";
|
|
37
|
+
AggregationType["AggregateReserveAction"] = "AggregateReserveAction";
|
|
36
38
|
AggregationType["AggregateTask"] = "AggregateTask";
|
|
37
39
|
AggregationType["AggregateUseAction"] = "AggregateUseAction";
|
|
38
40
|
})(AggregationType = exports.AggregationType || (exports.AggregationType = {}));
|
|
@@ -84,6 +84,34 @@ declare function aggregateUseAction(params: {
|
|
|
84
84
|
aggregationCount: number;
|
|
85
85
|
aggregateDuration: string;
|
|
86
86
|
}>;
|
|
87
|
+
/**
|
|
88
|
+
* 予約アクション集計
|
|
89
|
+
*/
|
|
90
|
+
declare function aggregateReserveAction(params: {
|
|
91
|
+
aggregateDurationUnit: AggregateDurationUnit;
|
|
92
|
+
aggregationCount: number;
|
|
93
|
+
excludedProjectId?: string;
|
|
94
|
+
}): (repos: {
|
|
95
|
+
agregation: AggregationRepo;
|
|
96
|
+
action: ActionRepo;
|
|
97
|
+
}) => Promise<{
|
|
98
|
+
aggregationCount: number;
|
|
99
|
+
aggregateDuration: string;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* 注文アクション集計
|
|
103
|
+
*/
|
|
104
|
+
declare function aggregateOrderAction(params: {
|
|
105
|
+
aggregateDurationUnit: AggregateDurationUnit;
|
|
106
|
+
aggregationCount: number;
|
|
107
|
+
excludedProjectId?: string;
|
|
108
|
+
}): (repos: {
|
|
109
|
+
agregation: AggregationRepo;
|
|
110
|
+
action: ActionRepo;
|
|
111
|
+
}) => Promise<{
|
|
112
|
+
aggregationCount: number;
|
|
113
|
+
aggregateDuration: string;
|
|
114
|
+
}>;
|
|
87
115
|
declare function aggregateCheckMovieTicketAction(params: {
|
|
88
116
|
aggregateDurationUnit: AggregateDurationUnit;
|
|
89
117
|
aggregationCount: number;
|
|
@@ -142,4 +170,4 @@ declare function aggregateTask(params: {
|
|
|
142
170
|
aggregationCount: number;
|
|
143
171
|
aggregateDuration: string;
|
|
144
172
|
}>;
|
|
145
|
-
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregatePayMovieTicketAction, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
|
|
173
|
+
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregateOrderAction, aggregatePayMovieTicketAction, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveAction, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
|
|
@@ -9,7 +9,7 @@ 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.aggregatePayMovieTicketAction = exports.aggregateEvent = exports.aggregateCheckMovieTicketAction = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
|
|
12
|
+
exports.aggregateUseAction = exports.aggregateTask = exports.aggregateReserveTransaction = exports.aggregateReserveAction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = exports.aggregatePayMovieTicketAction = exports.aggregateOrderAction = exports.aggregateEvent = exports.aggregateCheckMovieTicketAction = 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");
|
|
@@ -235,7 +235,7 @@ function aggregateUseAction(params) {
|
|
|
235
235
|
.add(-i, params.aggregateDurationUnit)
|
|
236
236
|
.endOf(params.aggregateDurationUnit)
|
|
237
237
|
.toDate();
|
|
238
|
-
const aggregateResult = yield repos.action.
|
|
238
|
+
const aggregateResult = yield repos.action.aggregateByTypeOf({
|
|
239
239
|
project: { id: { $ne: params.excludedProjectId } },
|
|
240
240
|
startFrom,
|
|
241
241
|
startThrough,
|
|
@@ -248,6 +248,80 @@ function aggregateUseAction(params) {
|
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
exports.aggregateUseAction = aggregateUseAction;
|
|
251
|
+
/**
|
|
252
|
+
* 予約アクション集計
|
|
253
|
+
*/
|
|
254
|
+
function aggregateReserveAction(params) {
|
|
255
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
var _a;
|
|
257
|
+
const aggregateDate = new Date();
|
|
258
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
259
|
+
.toISOString();
|
|
260
|
+
let i = -1;
|
|
261
|
+
while (i < params.aggregationCount) {
|
|
262
|
+
i += 1;
|
|
263
|
+
const startFrom = moment(aggregateDate)
|
|
264
|
+
.utc()
|
|
265
|
+
// .tz('Asia/Tokyo')
|
|
266
|
+
.add(-i, params.aggregateDurationUnit)
|
|
267
|
+
.startOf(params.aggregateDurationUnit)
|
|
268
|
+
.toDate();
|
|
269
|
+
const startThrough = moment(aggregateDate)
|
|
270
|
+
.utc()
|
|
271
|
+
// .tz('Asia/Tokyo')
|
|
272
|
+
.add(-i, params.aggregateDurationUnit)
|
|
273
|
+
.endOf(params.aggregateDurationUnit)
|
|
274
|
+
.toDate();
|
|
275
|
+
const aggregateResult = yield repos.action.aggregateByTypeOf({
|
|
276
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
277
|
+
startFrom,
|
|
278
|
+
startThrough,
|
|
279
|
+
typeOf: factory.actionType.ReserveAction
|
|
280
|
+
});
|
|
281
|
+
debug('aggregateReserveAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
282
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateReserveAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
283
|
+
}
|
|
284
|
+
return { aggregationCount: i, aggregateDuration };
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
exports.aggregateReserveAction = aggregateReserveAction;
|
|
288
|
+
/**
|
|
289
|
+
* 注文アクション集計
|
|
290
|
+
*/
|
|
291
|
+
function aggregateOrderAction(params) {
|
|
292
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
293
|
+
var _a;
|
|
294
|
+
const aggregateDate = new Date();
|
|
295
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
296
|
+
.toISOString();
|
|
297
|
+
let i = -1;
|
|
298
|
+
while (i < params.aggregationCount) {
|
|
299
|
+
i += 1;
|
|
300
|
+
const startFrom = moment(aggregateDate)
|
|
301
|
+
.utc()
|
|
302
|
+
// .tz('Asia/Tokyo')
|
|
303
|
+
.add(-i, params.aggregateDurationUnit)
|
|
304
|
+
.startOf(params.aggregateDurationUnit)
|
|
305
|
+
.toDate();
|
|
306
|
+
const startThrough = moment(aggregateDate)
|
|
307
|
+
.utc()
|
|
308
|
+
// .tz('Asia/Tokyo')
|
|
309
|
+
.add(-i, params.aggregateDurationUnit)
|
|
310
|
+
.endOf(params.aggregateDurationUnit)
|
|
311
|
+
.toDate();
|
|
312
|
+
const aggregateResult = yield repos.action.aggregateByTypeOf({
|
|
313
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
314
|
+
startFrom,
|
|
315
|
+
startThrough,
|
|
316
|
+
typeOf: factory.actionType.OrderAction
|
|
317
|
+
});
|
|
318
|
+
debug('aggregateOrderAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
319
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateOrderAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
320
|
+
}
|
|
321
|
+
return { aggregationCount: i, aggregateDuration };
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
exports.aggregateOrderAction = aggregateOrderAction;
|
|
251
325
|
function aggregateCheckMovieTicketAction(params) {
|
|
252
326
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
253
327
|
var _a;
|
|
@@ -768,7 +768,7 @@ function updateEvent4ttts(params) {
|
|
|
768
768
|
}
|
|
769
769
|
// アクション完了
|
|
770
770
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: {} });
|
|
771
|
-
yield (0, offer_1.onEventChanged)({ event, isNew: false })({
|
|
771
|
+
yield (0, offer_1.onEventChanged)({ event, isNew: false, useInform: true })({
|
|
772
772
|
event: repos.event,
|
|
773
773
|
project: repos.project,
|
|
774
774
|
task: repos.task
|
|
@@ -206,7 +206,10 @@ function createInformTasks(params) {
|
|
|
206
206
|
const events4inform = yield repos.event.search({
|
|
207
207
|
id: { $in: params.ids },
|
|
208
208
|
typeOf: params.typeOf
|
|
209
|
-
}, {
|
|
209
|
+
}, {
|
|
210
|
+
aggregateEntranceGate: 0, aggregateOffer: 0, aggregateReservation: 0,
|
|
211
|
+
remainingAttendeeCapacity: 0, checkInCount: 0, attendeeCount: 0
|
|
212
|
+
});
|
|
210
213
|
if (events4inform.length > 0) {
|
|
211
214
|
const taskRunsAt = new Date();
|
|
212
215
|
const informTasks = [];
|
package/package.json
CHANGED