@chevre/domain 21.2.0-alpha.7 → 21.2.0-alpha.9
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/countDelayedTasks.ts +17 -0
- package/example/src/chevre/countDelayedTransactions.ts +60 -0
- package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
- package/lib/chevre/repo/assetTransaction.js +5 -0
- package/lib/chevre/repo/task.d.ts +3 -0
- package/lib/chevre/repo/task.js +12 -0
- package/package.json +2 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
export async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
|
+
|
|
9
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const count = await taskRepo.countDelayedTasks({ delayInSeconds: 60 });
|
|
12
|
+
console.log('count:', count);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
main()
|
|
16
|
+
.then()
|
|
17
|
+
.catch(console.error);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
export async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
|
+
|
|
9
|
+
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
10
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
for (const typeOf of [
|
|
13
|
+
chevre.factory.transactionType.PlaceOrder,
|
|
14
|
+
chevre.factory.transactionType.ReturnOrder,
|
|
15
|
+
chevre.factory.transactionType.MoneyTransfer
|
|
16
|
+
]) {
|
|
17
|
+
const count = await transactionRepo.count({
|
|
18
|
+
typeOf,
|
|
19
|
+
statuses: [
|
|
20
|
+
chevre.factory.transactionStatusType.Canceled,
|
|
21
|
+
chevre.factory.transactionStatusType.Confirmed,
|
|
22
|
+
chevre.factory.transactionStatusType.Expired
|
|
23
|
+
],
|
|
24
|
+
tasksExportationStatuses: [
|
|
25
|
+
chevre.factory.transactionTasksExportationStatus.Exporting,
|
|
26
|
+
chevre.factory.transactionTasksExportationStatus.Unexported
|
|
27
|
+
],
|
|
28
|
+
endThrough: new Date()
|
|
29
|
+
});
|
|
30
|
+
console.log('count:', count, typeOf);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (const typeOf of [
|
|
34
|
+
chevre.factory.assetTransactionType.CancelReservation,
|
|
35
|
+
chevre.factory.assetTransactionType.MoneyTransfer,
|
|
36
|
+
chevre.factory.assetTransactionType.Pay,
|
|
37
|
+
chevre.factory.assetTransactionType.Refund,
|
|
38
|
+
chevre.factory.assetTransactionType.RegisterService,
|
|
39
|
+
chevre.factory.assetTransactionType.Reserve
|
|
40
|
+
]) {
|
|
41
|
+
const count = await assetTransactionRepo.count({
|
|
42
|
+
typeOf,
|
|
43
|
+
statuses: [
|
|
44
|
+
chevre.factory.transactionStatusType.Canceled,
|
|
45
|
+
chevre.factory.transactionStatusType.Confirmed,
|
|
46
|
+
chevre.factory.transactionStatusType.Expired
|
|
47
|
+
],
|
|
48
|
+
tasksExportationStatuses: [
|
|
49
|
+
chevre.factory.transactionTasksExportationStatus.Exporting,
|
|
50
|
+
chevre.factory.transactionTasksExportationStatus.Unexported
|
|
51
|
+
],
|
|
52
|
+
endThrough: new Date()
|
|
53
|
+
});
|
|
54
|
+
console.log('count:', count, typeOf);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
main()
|
|
59
|
+
.then()
|
|
60
|
+
.catch(console.error);
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
export async function main() {
|
|
11
|
+
const now = new Date();
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
+
|
|
14
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const transactions = await transactionRepo.search<chevre.factory.transactionType.MoneyTransfer>(
|
|
17
|
+
{
|
|
18
|
+
project: { id: { $eq: project.id } },
|
|
19
|
+
typeOf: chevre.factory.transactionType.MoneyTransfer,
|
|
20
|
+
statuses: [chevre.factory.transactionStatusType.Confirmed],
|
|
21
|
+
startFrom: moment(now)
|
|
22
|
+
.add(-1, 'year')
|
|
23
|
+
.toDate(),
|
|
24
|
+
startThrough: now,
|
|
25
|
+
inclusion: ['_id', 'startDate', 'typeOf', 'object'],
|
|
26
|
+
exclusion: []
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
const count = transactions.filter((t) => t.object.description === '受け取り')
|
|
30
|
+
.length;
|
|
31
|
+
console.log('transactions found', count);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main()
|
|
35
|
+
.then()
|
|
36
|
+
.catch(console.error);
|
|
@@ -102,6 +102,11 @@ class MongoRepository {
|
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
+
if (Array.isArray(params.tasksExportationStatuses)) {
|
|
106
|
+
andConditions.push({
|
|
107
|
+
tasksExportationStatus: { $in: params.tasksExportationStatuses }
|
|
108
|
+
});
|
|
109
|
+
}
|
|
105
110
|
switch (params.typeOf) {
|
|
106
111
|
case factory.assetTransactionType.Pay:
|
|
107
112
|
const objectAccountIdEq = (_e = (_d = params.object) === null || _d === void 0 ? void 0 : _d.accountId) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
@@ -61,6 +61,9 @@ export declare class MongoRepository {
|
|
|
61
61
|
deleteByName(params: {
|
|
62
62
|
name: factory.taskName;
|
|
63
63
|
}): Promise<import("mongodb").DeleteResult>;
|
|
64
|
+
countDelayedTasks(params: {
|
|
65
|
+
delayInSeconds: number;
|
|
66
|
+
}): Promise<number>;
|
|
64
67
|
aggregateTask(params: {
|
|
65
68
|
project?: {
|
|
66
69
|
id?: {
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -340,6 +340,18 @@ class MongoRepository {
|
|
|
340
340
|
.exec();
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
|
+
countDelayedTasks(params) {
|
|
344
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
345
|
+
const runsAtLt = moment()
|
|
346
|
+
.add(-params.delayInSeconds, 'seconds')
|
|
347
|
+
.toDate();
|
|
348
|
+
return this.taskModel.count({
|
|
349
|
+
status: factory.taskStatus.Ready,
|
|
350
|
+
runsAt: { $lt: runsAtLt }
|
|
351
|
+
})
|
|
352
|
+
.exec();
|
|
353
|
+
});
|
|
354
|
+
}
|
|
343
355
|
aggregateTask(params) {
|
|
344
356
|
return __awaiter(this, void 0, void 0, function* () {
|
|
345
357
|
const statuses = yield Promise.all([
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.311.0",
|
|
13
13
|
"@cinerino/sdk": "3.154.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.9"
|
|
121
121
|
}
|