@chevre/domain 21.2.0-alpha.105 → 21.2.0-alpha.106
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 +13 -0
- package/lib/chevre/repo/action.d.ts +9 -0
- package/lib/chevre/repo/action.js +26 -0
- package/lib/chevre/repo/aggregation.d.ts +1 -0
- package/lib/chevre/repo/aggregation.js +1 -0
- package/lib/chevre/service/aggregation/system.d.ts +15 -1
- package/lib/chevre/service/aggregation/system.js +37 -1
- package/package.json +1 -1
|
@@ -22,6 +22,19 @@ async function main() {
|
|
|
22
22
|
|
|
23
23
|
let result: { aggregationCount: number; aggregateDuration: string };
|
|
24
24
|
|
|
25
|
+
result = await chevre.service.aggregation.system.aggregateCancelReservationAction({
|
|
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('aggregateCancelReservationAction processed.', result);
|
|
36
|
+
return;
|
|
37
|
+
|
|
25
38
|
result = await chevre.service.aggregation.system.aggregateReserveAction({
|
|
26
39
|
aggregateDurationUnit: 'hours',
|
|
27
40
|
// aggregateDurationUnit: 'days',
|
|
@@ -180,6 +180,15 @@ export declare class MongoRepository {
|
|
|
180
180
|
startThrough: Date;
|
|
181
181
|
typeOf: factory.actionType;
|
|
182
182
|
}): Promise<IAggregateAction>;
|
|
183
|
+
aggregateCancelReservationAction(params: {
|
|
184
|
+
project?: {
|
|
185
|
+
id?: {
|
|
186
|
+
$ne?: string;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
startFrom: Date;
|
|
190
|
+
startThrough: Date;
|
|
191
|
+
}): Promise<IAggregateAction>;
|
|
183
192
|
/**
|
|
184
193
|
* アクションタイプによる汎用的な集計
|
|
185
194
|
*/
|
|
@@ -801,6 +801,32 @@ class MongoRepository {
|
|
|
801
801
|
return { statuses };
|
|
802
802
|
});
|
|
803
803
|
}
|
|
804
|
+
aggregateCancelReservationAction(params) {
|
|
805
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
806
|
+
const statuses = yield Promise.all([
|
|
807
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
808
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
809
|
+
factory.actionStatusType.FailedActionStatus
|
|
810
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
811
|
+
var _a, _b;
|
|
812
|
+
const matchConditions = Object.assign({ startDate: {
|
|
813
|
+
$gte: params.startFrom,
|
|
814
|
+
$lte: params.startThrough
|
|
815
|
+
}, typeOf: { $eq: factory.actionType.CancelAction }, actionStatus: { $eq: actionStatus }, 'object.typeOf': {
|
|
816
|
+
$exists: true,
|
|
817
|
+
$in: [
|
|
818
|
+
factory.reservationType.BusReservation,
|
|
819
|
+
factory.reservationType.EventReservation,
|
|
820
|
+
factory.reservationType.ReservationPackage
|
|
821
|
+
]
|
|
822
|
+
} }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
823
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
824
|
+
: undefined);
|
|
825
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
826
|
+
})));
|
|
827
|
+
return { statuses };
|
|
828
|
+
});
|
|
829
|
+
}
|
|
804
830
|
/**
|
|
805
831
|
* アクションタイプによる汎用的な集計
|
|
806
832
|
*/
|
|
@@ -4,6 +4,7 @@ export declare enum AggregationType {
|
|
|
4
4
|
AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
|
|
5
5
|
AggregateAuthorizeOrderAction = "AggregateAuthorizeOrderAction",
|
|
6
6
|
AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
|
|
7
|
+
AggregateCancelReservationAction = "AggregateCancelReservationAction",
|
|
7
8
|
AggregateCheckMovieTicketAction = "AggregateCheckMovieTicketAction",
|
|
8
9
|
AggregateEvent = "AggregateEvent",
|
|
9
10
|
AggregateOrderAction = "AggregateOrderAction",
|
|
@@ -27,6 +27,7 @@ var AggregationType;
|
|
|
27
27
|
AggregationType["AggregateAuthorizeEventServiceOfferAction"] = "AggregateAuthorizeEventServiceOfferAction";
|
|
28
28
|
AggregationType["AggregateAuthorizeOrderAction"] = "AggregateAuthorizeOrderAction";
|
|
29
29
|
AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
|
|
30
|
+
AggregationType["AggregateCancelReservationAction"] = "AggregateCancelReservationAction";
|
|
30
31
|
AggregationType["AggregateCheckMovieTicketAction"] = "AggregateCheckMovieTicketAction";
|
|
31
32
|
AggregationType["AggregateEvent"] = "AggregateEvent";
|
|
32
33
|
AggregationType["AggregateOrderAction"] = "AggregateOrderAction";
|
|
@@ -112,6 +112,20 @@ declare function aggregateOrderAction(params: {
|
|
|
112
112
|
aggregationCount: number;
|
|
113
113
|
aggregateDuration: string;
|
|
114
114
|
}>;
|
|
115
|
+
/**
|
|
116
|
+
* 予約取消アクション集計
|
|
117
|
+
*/
|
|
118
|
+
declare function aggregateCancelReservationAction(params: {
|
|
119
|
+
aggregateDurationUnit: AggregateDurationUnit;
|
|
120
|
+
aggregationCount: number;
|
|
121
|
+
excludedProjectId?: string;
|
|
122
|
+
}): (repos: {
|
|
123
|
+
agregation: AggregationRepo;
|
|
124
|
+
action: ActionRepo;
|
|
125
|
+
}) => Promise<{
|
|
126
|
+
aggregationCount: number;
|
|
127
|
+
aggregateDuration: string;
|
|
128
|
+
}>;
|
|
115
129
|
declare function aggregateCheckMovieTicketAction(params: {
|
|
116
130
|
aggregateDurationUnit: AggregateDurationUnit;
|
|
117
131
|
aggregationCount: number;
|
|
@@ -170,4 +184,4 @@ declare function aggregateTask(params: {
|
|
|
170
184
|
aggregationCount: number;
|
|
171
185
|
aggregateDuration: string;
|
|
172
186
|
}>;
|
|
173
|
-
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregateOrderAction, aggregatePayMovieTicketAction, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveAction, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
|
|
187
|
+
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCancelReservationAction, 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.aggregateReserveAction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = exports.aggregatePayMovieTicketAction = exports.aggregateOrderAction = 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.aggregateCancelReservationAction = 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");
|
|
@@ -322,6 +322,42 @@ function aggregateOrderAction(params) {
|
|
|
322
322
|
});
|
|
323
323
|
}
|
|
324
324
|
exports.aggregateOrderAction = aggregateOrderAction;
|
|
325
|
+
/**
|
|
326
|
+
* 予約取消アクション集計
|
|
327
|
+
*/
|
|
328
|
+
function aggregateCancelReservationAction(params) {
|
|
329
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
330
|
+
var _a;
|
|
331
|
+
const aggregateDate = new Date();
|
|
332
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
333
|
+
.toISOString();
|
|
334
|
+
let i = -1;
|
|
335
|
+
while (i < params.aggregationCount) {
|
|
336
|
+
i += 1;
|
|
337
|
+
const startFrom = moment(aggregateDate)
|
|
338
|
+
.utc()
|
|
339
|
+
// .tz('Asia/Tokyo')
|
|
340
|
+
.add(-i, params.aggregateDurationUnit)
|
|
341
|
+
.startOf(params.aggregateDurationUnit)
|
|
342
|
+
.toDate();
|
|
343
|
+
const startThrough = moment(aggregateDate)
|
|
344
|
+
.utc()
|
|
345
|
+
// .tz('Asia/Tokyo')
|
|
346
|
+
.add(-i, params.aggregateDurationUnit)
|
|
347
|
+
.endOf(params.aggregateDurationUnit)
|
|
348
|
+
.toDate();
|
|
349
|
+
const aggregateResult = yield repos.action.aggregateCancelReservationAction({
|
|
350
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
351
|
+
startFrom,
|
|
352
|
+
startThrough
|
|
353
|
+
});
|
|
354
|
+
debug('aggregateCancelReservationAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
355
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateCancelReservationAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
356
|
+
}
|
|
357
|
+
return { aggregationCount: i, aggregateDuration };
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
exports.aggregateCancelReservationAction = aggregateCancelReservationAction;
|
|
325
361
|
function aggregateCheckMovieTicketAction(params) {
|
|
326
362
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
327
363
|
var _a;
|
package/package.json
CHANGED