@chevre/domain 20.2.0-alpha.19 → 20.2.0-alpha.20
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 +10 -2
- package/lib/chevre/repo/action.d.ts +10 -0
- package/lib/chevre/repo/action.js +22 -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 +8 -1
- package/lib/chevre/service/aggregation/system.js +32 -1
- package/package.json +1 -1
|
@@ -16,12 +16,12 @@ async function main() {
|
|
|
16
16
|
const orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
17
17
|
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
18
18
|
|
|
19
|
-
await chevre.service.aggregation.system.
|
|
19
|
+
await chevre.service.aggregation.system.aggregateAuthorizeOrderAction({
|
|
20
20
|
aggregationDays: AGGREGATE_DAYS,
|
|
21
21
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
22
22
|
})({
|
|
23
23
|
agregation: aggregationRepo,
|
|
24
|
-
|
|
24
|
+
action: actionRepo
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
|
|
@@ -48,6 +48,14 @@ async function main() {
|
|
|
48
48
|
action: actionRepo
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
await chevre.service.aggregation.system.aggregatePlaceOrder({
|
|
52
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
53
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
54
|
+
})({
|
|
55
|
+
agregation: aggregationRepo,
|
|
56
|
+
transaction: transactionRepo
|
|
57
|
+
});
|
|
58
|
+
|
|
51
59
|
await chevre.service.aggregation.system.aggregateOrder({
|
|
52
60
|
aggregationDays: AGGREGATE_DAYS,
|
|
53
61
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
@@ -144,6 +144,16 @@ export declare class MongoRepository {
|
|
|
144
144
|
startThrough: Date;
|
|
145
145
|
typeOf: factory.actionType;
|
|
146
146
|
}): Promise<IAggregateAction>;
|
|
147
|
+
aggregateAuthorizeOrderAction(params: {
|
|
148
|
+
project?: {
|
|
149
|
+
id?: {
|
|
150
|
+
$ne?: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
startFrom: Date;
|
|
154
|
+
startThrough: Date;
|
|
155
|
+
typeOf: factory.actionType;
|
|
156
|
+
}): Promise<IAggregateAction>;
|
|
147
157
|
aggregateUseAction(params: {
|
|
148
158
|
project?: {
|
|
149
159
|
id?: {
|
|
@@ -721,6 +721,28 @@ class MongoRepository {
|
|
|
721
721
|
return { statuses };
|
|
722
722
|
});
|
|
723
723
|
}
|
|
724
|
+
aggregateAuthorizeOrderAction(params) {
|
|
725
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
726
|
+
const statuses = yield Promise.all([
|
|
727
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
728
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
729
|
+
factory.actionStatusType.FailedActionStatus
|
|
730
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
731
|
+
var _a, _b;
|
|
732
|
+
const matchConditions = Object.assign({ startDate: {
|
|
733
|
+
$gte: params.startFrom,
|
|
734
|
+
$lte: params.startThrough
|
|
735
|
+
}, typeOf: { $eq: params.typeOf }, actionStatus: { $eq: actionStatus }, 'object.typeOf': {
|
|
736
|
+
$exists: true,
|
|
737
|
+
$eq: factory.order.OrderType.Order
|
|
738
|
+
} }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
739
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
740
|
+
: undefined);
|
|
741
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
742
|
+
})));
|
|
743
|
+
return { statuses };
|
|
744
|
+
});
|
|
745
|
+
}
|
|
724
746
|
aggregateUseAction(params) {
|
|
725
747
|
return __awaiter(this, void 0, void 0, function* () {
|
|
726
748
|
const statuses = yield Promise.all([
|
|
@@ -3,6 +3,7 @@ import * as factory from '../factory';
|
|
|
3
3
|
export declare enum AggregationType {
|
|
4
4
|
AggregatePlaceOrder = "AggregatePlaceOrder",
|
|
5
5
|
AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
|
|
6
|
+
AggregateAuthorizeOrderAction = "AggregateAuthorizeOrderAction",
|
|
6
7
|
AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
|
|
7
8
|
AggregateOrder = "AggregateOrder",
|
|
8
9
|
AggregateReservation = "AggregateReservation",
|
|
@@ -26,6 +26,7 @@ var AggregationType;
|
|
|
26
26
|
(function (AggregationType) {
|
|
27
27
|
AggregationType["AggregatePlaceOrder"] = "AggregatePlaceOrder";
|
|
28
28
|
AggregationType["AggregateAuthorizeEventServiceOfferAction"] = "AggregateAuthorizeEventServiceOfferAction";
|
|
29
|
+
AggregationType["AggregateAuthorizeOrderAction"] = "AggregateAuthorizeOrderAction";
|
|
29
30
|
AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
|
|
30
31
|
AggregationType["AggregateOrder"] = "AggregateOrder";
|
|
31
32
|
AggregationType["AggregateReservation"] = "AggregateReservation";
|
|
@@ -33,6 +33,13 @@ declare function aggregateAuthorizePaymentAction(params: {
|
|
|
33
33
|
agregation: AggregationRepo;
|
|
34
34
|
action: ActionRepo;
|
|
35
35
|
}) => Promise<void>;
|
|
36
|
+
declare function aggregateAuthorizeOrderAction(params: {
|
|
37
|
+
aggregationDays: number;
|
|
38
|
+
excludedProjectId?: string;
|
|
39
|
+
}): (repos: {
|
|
40
|
+
agregation: AggregationRepo;
|
|
41
|
+
action: ActionRepo;
|
|
42
|
+
}) => Promise<void>;
|
|
36
43
|
/**
|
|
37
44
|
* 使用アクション集計
|
|
38
45
|
*/
|
|
@@ -63,4 +70,4 @@ declare function aggregateReservation(params: {
|
|
|
63
70
|
agregation: AggregationRepo;
|
|
64
71
|
reservation: ReservationRepo;
|
|
65
72
|
}) => Promise<void>;
|
|
66
|
-
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizePaymentAction, aggregateOrder, aggregatePlaceOrder, aggregateReservation, aggregateUseAction };
|
|
73
|
+
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateOrder, aggregatePlaceOrder, aggregateReservation, 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.aggregateReservation = exports.aggregatePlaceOrder = exports.aggregateOrder = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
|
|
12
|
+
exports.aggregateUseAction = exports.aggregateReservation = exports.aggregatePlaceOrder = exports.aggregateOrder = 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");
|
|
@@ -117,6 +117,37 @@ function aggregateAuthorizePaymentAction(params) {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
exports.aggregateAuthorizePaymentAction = aggregateAuthorizePaymentAction;
|
|
120
|
+
function aggregateAuthorizeOrderAction(params) {
|
|
121
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
var _a;
|
|
123
|
+
const aggregateDate = new Date();
|
|
124
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
125
|
+
.toISOString();
|
|
126
|
+
let i = -1;
|
|
127
|
+
while (i < params.aggregationDays) {
|
|
128
|
+
i += 1;
|
|
129
|
+
const startFrom = moment()
|
|
130
|
+
// .tz('Asia/Tokyo')
|
|
131
|
+
.add(-i, 'days')
|
|
132
|
+
.startOf('day')
|
|
133
|
+
.toDate();
|
|
134
|
+
const startThrough = moment()
|
|
135
|
+
// .tz('Asia/Tokyo')
|
|
136
|
+
.add(-i, 'days')
|
|
137
|
+
.endOf('day')
|
|
138
|
+
.toDate();
|
|
139
|
+
const aggregateResult = yield repos.action.aggregateAuthorizeOrderAction({
|
|
140
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
141
|
+
startFrom,
|
|
142
|
+
startThrough,
|
|
143
|
+
typeOf: factory.actionType.AuthorizeAction
|
|
144
|
+
});
|
|
145
|
+
debug('aggregateAuthorizeOrderAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
146
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizeOrderAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
exports.aggregateAuthorizeOrderAction = aggregateAuthorizeOrderAction;
|
|
120
151
|
/**
|
|
121
152
|
* 使用アクション集計
|
|
122
153
|
*/
|
package/package.json
CHANGED