@chevre/domain 21.30.0-alpha.10 → 21.30.0-alpha.12
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.
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const lt: Date = moment()
|
|
13
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
14
|
+
.add(-16, 'months')
|
|
15
|
+
.toDate();
|
|
16
|
+
let result: any;
|
|
17
|
+
result = await actionRepo.deleteStartDatePassedCertainPeriod({
|
|
18
|
+
$lt: lt
|
|
19
|
+
});
|
|
20
|
+
console.log('result:', result, lt);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
main()
|
|
24
|
+
.then(() => {
|
|
25
|
+
console.log('success!');
|
|
26
|
+
})
|
|
27
|
+
.catch(console.error);
|
|
@@ -13,13 +13,14 @@ async function main() {
|
|
|
13
13
|
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
14
14
|
|
|
15
15
|
// tslint:disable-next-line:no-increment-decrement no-magic-numbers
|
|
16
|
-
for (let index = 0; index < 24 *
|
|
16
|
+
for (let index = 0; index < 24 * 1000; index++) {
|
|
17
17
|
const updateResult = await actionRepo.unsetUnnecessaryFields({
|
|
18
18
|
filter: {
|
|
19
|
-
typeOf: { $eq: chevre.factory.actionType.OrderAction },
|
|
20
|
-
'
|
|
21
|
-
// '
|
|
19
|
+
// typeOf: { $eq: chevre.factory.actionType.OrderAction },
|
|
20
|
+
'agent.typeOf': { $exists: true, $eq: chevre.factory.creativeWorkType.WebApplication },
|
|
21
|
+
// 'agent.typeOf': { $exists: true, $eq: chevre.factory.personType.Person },
|
|
22
22
|
startDate: {
|
|
23
|
+
// $exists: true,
|
|
23
24
|
$gte: moment()
|
|
24
25
|
.add(-(index + 1), 'hours')
|
|
25
26
|
.toDate(),
|
|
@@ -30,24 +31,27 @@ async function main() {
|
|
|
30
31
|
// _id: { $eq: '61da235d94a80f000af85f6b' }
|
|
31
32
|
},
|
|
32
33
|
$unset: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'object.
|
|
40
|
-
'object.
|
|
41
|
-
'object.
|
|
42
|
-
'object.
|
|
43
|
-
'object.
|
|
44
|
-
'object.
|
|
45
|
-
'object.
|
|
46
|
-
'object.
|
|
47
|
-
'object.
|
|
48
|
-
'object.
|
|
49
|
-
'object.
|
|
50
|
-
'object.
|
|
34
|
+
'agent.identifier': 1,
|
|
35
|
+
'agent.memberOf': 1,
|
|
36
|
+
'agent.email': 1,
|
|
37
|
+
'agent.familyName': 1,
|
|
38
|
+
'agent.givenName': 1,
|
|
39
|
+
'agent.telephone': 1
|
|
40
|
+
// 'object.project': 1,
|
|
41
|
+
// 'object.seller': 1,
|
|
42
|
+
// 'object.customer': 1,
|
|
43
|
+
// 'object.paymentMethods': 1,
|
|
44
|
+
// 'object.discounts': 1,
|
|
45
|
+
// 'object.acceptedOffers': 1,
|
|
46
|
+
// 'object.url': 1,
|
|
47
|
+
// 'object.orderStatus': 1,
|
|
48
|
+
// 'object.identifier': 1,
|
|
49
|
+
// 'object.isGift': 1,
|
|
50
|
+
// 'object.broker': 1,
|
|
51
|
+
// 'object.dateReturned': 1,
|
|
52
|
+
// 'object.name': 1,
|
|
53
|
+
// 'object.orderedItem': 1,
|
|
54
|
+
// 'object.returner': 1
|
|
51
55
|
}
|
|
52
56
|
});
|
|
53
57
|
console.log(
|
|
@@ -47,6 +47,10 @@ interface IOptionOnCreate {
|
|
|
47
47
|
export type IExecutableTaskKeys = 'data' | 'id' | 'name' | 'status' | 'numberOfTried' | 'project' | 'remainingNumberOfTries' | 'runsAt' | 'expires';
|
|
48
48
|
export type IExecutableTask<T extends factory.taskName> = Pick<factory.task.ITask<T>, IExecutableTaskKeys>;
|
|
49
49
|
type IDelayedTask = Pick<factory.task.ITask<factory.taskName>, 'id' | 'name' | 'status'>;
|
|
50
|
+
type IKeyOfProjection = keyof factory.task.ITask<factory.taskName> | '_id';
|
|
51
|
+
type IProjection = {
|
|
52
|
+
[key in IKeyOfProjection]?: 0;
|
|
53
|
+
};
|
|
50
54
|
/**
|
|
51
55
|
* タスクリポジトリ
|
|
52
56
|
*/
|
|
@@ -114,7 +118,14 @@ export declare class MongoRepository {
|
|
|
114
118
|
abortMany(params: {
|
|
115
119
|
intervalInMinutes: number;
|
|
116
120
|
}): Promise<UpdateWriteOpResult>;
|
|
117
|
-
|
|
121
|
+
/**
|
|
122
|
+
* 実行結果を保管する
|
|
123
|
+
*/
|
|
124
|
+
pushExecutionResultById(
|
|
125
|
+
/**
|
|
126
|
+
* タスクID
|
|
127
|
+
*/
|
|
128
|
+
id: string, status: factory.taskStatus, executionResult: factory.task.IExecutionResult): Promise<void>;
|
|
118
129
|
/**
|
|
119
130
|
* 特定タスク検索
|
|
120
131
|
*/
|
|
@@ -126,7 +137,7 @@ export declare class MongoRepository {
|
|
|
126
137
|
/**
|
|
127
138
|
* 検索する
|
|
128
139
|
*/
|
|
129
|
-
search(params: factory.task.ISearchConditions, projection?:
|
|
140
|
+
search(params: factory.task.ISearchConditions, projection?: IProjection): Promise<factory.task.ITask<factory.taskName>[]>;
|
|
130
141
|
deleteByProject(params: {
|
|
131
142
|
project: {
|
|
132
143
|
id: string;
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -526,10 +526,17 @@ class MongoRepository {
|
|
|
526
526
|
.exec();
|
|
527
527
|
});
|
|
528
528
|
}
|
|
529
|
-
|
|
529
|
+
/**
|
|
530
|
+
* 実行結果を保管する
|
|
531
|
+
*/
|
|
532
|
+
pushExecutionResultById(
|
|
533
|
+
/**
|
|
534
|
+
* タスクID
|
|
535
|
+
*/
|
|
536
|
+
id, status, executionResult) {
|
|
530
537
|
return __awaiter(this, void 0, void 0, function* () {
|
|
531
|
-
yield this.taskModel.
|
|
532
|
-
|
|
538
|
+
yield this.taskModel.updateOne({ _id: { $eq: id } }, {
|
|
539
|
+
$set: { status },
|
|
533
540
|
$push: { executionResults: executionResult }
|
|
534
541
|
})
|
|
535
542
|
.exec();
|
|
@@ -541,8 +548,8 @@ class MongoRepository {
|
|
|
541
548
|
findById(params) {
|
|
542
549
|
return __awaiter(this, void 0, void 0, function* () {
|
|
543
550
|
const doc = yield this.taskModel.findOne({
|
|
544
|
-
name: params.name,
|
|
545
|
-
_id: params.id
|
|
551
|
+
name: { $eq: params.name },
|
|
552
|
+
_id: { $eq: params.id }
|
|
546
553
|
}, {
|
|
547
554
|
__v: 0,
|
|
548
555
|
createdAt: 0,
|
|
@@ -622,7 +629,8 @@ class MongoRepository {
|
|
|
622
629
|
const runsAtLt = moment()
|
|
623
630
|
.add(-params.delayInSeconds, 'seconds')
|
|
624
631
|
.toDate();
|
|
625
|
-
return this.taskModel.count(Object.assign({ status: factory.taskStatus.Ready, runsAt: { $lt: runsAtLt } }, (Array.isArray(params.name.$nin)) ? { name: { $nin: params.name.$nin } } : undefined))
|
|
632
|
+
return this.taskModel.count(Object.assign({ status: { $eq: factory.taskStatus.Ready }, runsAt: { $lt: runsAtLt } }, (Array.isArray(params.name.$nin)) ? { name: { $nin: params.name.$nin } } : undefined))
|
|
633
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
626
634
|
.exec();
|
|
627
635
|
});
|
|
628
636
|
}
|
|
@@ -77,11 +77,28 @@ function importFromCOA(params) {
|
|
|
77
77
|
// tslint:disable-next-line:max-func-body-length
|
|
78
78
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
79
79
|
const project = params.project;
|
|
80
|
+
const targetImportFrom = moment(`${moment(params.importFrom)
|
|
81
|
+
.tz('Asia/Tokyo')
|
|
82
|
+
.format('YYYY-MM-DD')}T00:00:00+09:00`);
|
|
83
|
+
const targetImportThrough = moment(`${moment(params.importThrough)
|
|
84
|
+
.tz('Asia/Tokyo')
|
|
85
|
+
.format('YYYY-MM-DD')}T00:00:00+09:00`)
|
|
86
|
+
.add(1, 'day');
|
|
87
|
+
const begin = moment(targetImportFrom)
|
|
88
|
+
.add(-1, 'day') // 深夜帯スケジュールが前日検索の結果に含まれるため
|
|
89
|
+
.tz('Asia/Tokyo')
|
|
90
|
+
.format('YYYYMMDD'); // COAは日本時間で判断
|
|
91
|
+
const end = moment(targetImportThrough)
|
|
92
|
+
.add(-1, 'day')
|
|
93
|
+
.tz('Asia/Tokyo')
|
|
94
|
+
.format('YYYYMMDD'); // COAは日本時間で判断
|
|
95
|
+
debug('importing screening events...', targetImportFrom, targetImportThrough, begin, end);
|
|
80
96
|
const actionAttributes = {
|
|
81
97
|
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
82
98
|
typeOf: factory.actionType.UpdateAction,
|
|
83
99
|
agent: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
84
|
-
object: Object.assign(Object.assign({}, params), {
|
|
100
|
+
object: Object.assign(Object.assign({}, params), { begin,
|
|
101
|
+
end, typeOf: factory.eventType.ScreeningEvent })
|
|
85
102
|
};
|
|
86
103
|
const action = yield repos.action.start(actionAttributes);
|
|
87
104
|
let savedScreeningEventsCount = 0;
|
|
@@ -126,14 +143,6 @@ function importFromCOA(params) {
|
|
|
126
143
|
project: { id: { $eq: project.id } },
|
|
127
144
|
containedInPlace: { branchCode: { $eq: movieTheater.branchCode } }
|
|
128
145
|
});
|
|
129
|
-
const targetImportFrom = moment(`${moment(params.importFrom)
|
|
130
|
-
.tz('Asia/Tokyo')
|
|
131
|
-
.format('YYYY-MM-DD')}T00:00:00+09:00`);
|
|
132
|
-
const targetImportThrough = moment(`${moment(params.importThrough)
|
|
133
|
-
.tz('Asia/Tokyo')
|
|
134
|
-
.format('YYYY-MM-DD')}T00:00:00+09:00`)
|
|
135
|
-
.add(1, 'day');
|
|
136
|
-
debug('importing screening events...', targetImportFrom, targetImportThrough);
|
|
137
146
|
const { screeningEventSerieses, savedEventsCount } = yield saveScreeningEventSeries({
|
|
138
147
|
locationBranchCode: params.locationBranchCode,
|
|
139
148
|
movieTheater,
|
package/package.json
CHANGED