@chevre/domain 21.2.0-alpha.113 → 21.2.0-alpha.115
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 +7 -2
- package/example/src/chevre/findMovieTheaterById.ts +40 -0
- package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +79 -0
- package/example/src/chevre/updateScreeningRoom.ts +41 -0
- package/lib/chevre/repo/event.js +4 -3
- package/lib/chevre/repo/place.d.ts +20 -5
- package/lib/chevre/repo/place.js +39 -3
- package/lib/chevre/repo/task.d.ts +3 -0
- package/lib/chevre/repo/task.js +1 -4
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +8 -6
- package/lib/chevre/service/task/onResourceUpdated.js +76 -0
- package/package.json +2 -2
- package/example/src/chevre/aggregateScreeningEventMaxVersion.ts +0 -27
|
@@ -4,11 +4,16 @@ import * as mongoose from 'mongoose';
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
6
|
export async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
8
|
|
|
9
9
|
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
10
10
|
|
|
11
|
-
const count = await taskRepo.countDelayedTasks({
|
|
11
|
+
const count = await taskRepo.countDelayedTasks({
|
|
12
|
+
delayInSeconds: 60,
|
|
13
|
+
name: {
|
|
14
|
+
$nin: [chevre.factory.taskName.OrderProgramMembership]
|
|
15
|
+
}
|
|
16
|
+
});
|
|
12
17
|
console.log('count:', count);
|
|
13
18
|
}
|
|
14
19
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const movieTheater = await placeRepo.findById(
|
|
14
|
+
{ id: '5d1da6853736344e714efbb8' },
|
|
15
|
+
[
|
|
16
|
+
'additionalProperty',
|
|
17
|
+
'branchCode',
|
|
18
|
+
'hasEntranceGate',
|
|
19
|
+
'hasPOS',
|
|
20
|
+
'kanaName',
|
|
21
|
+
'name',
|
|
22
|
+
'parentOrganization',
|
|
23
|
+
'project',
|
|
24
|
+
'telephone',
|
|
25
|
+
'url',
|
|
26
|
+
'typeOf',
|
|
27
|
+
'containsPlace.branchCode',
|
|
28
|
+
'containsPlace.name',
|
|
29
|
+
'containsPlace.typeOf',
|
|
30
|
+
'containsPlace.additionalProperty',
|
|
31
|
+
'containsPlace.address'
|
|
32
|
+
],
|
|
33
|
+
[]
|
|
34
|
+
);
|
|
35
|
+
console.log('place found', movieTheater);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
main()
|
|
39
|
+
.then(console.log)
|
|
40
|
+
.catch(console.error);
|
|
@@ -0,0 +1,79 @@
|
|
|
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 = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = eventRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
'project.id': {
|
|
19
|
+
// $eq: project.id,
|
|
20
|
+
$ne: EXCLUDED_PROJECT_ID
|
|
21
|
+
},
|
|
22
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
23
|
+
'workPerformed.version': { $exists: false }
|
|
24
|
+
// _id: { $eq: 'bl7ed6sq9' }
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
_id: 1,
|
|
28
|
+
workPerformed: 1,
|
|
29
|
+
project: 1,
|
|
30
|
+
location: 1,
|
|
31
|
+
startDate: 1,
|
|
32
|
+
typeOf: 1
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
console.log('events found');
|
|
36
|
+
|
|
37
|
+
let i = 0;
|
|
38
|
+
let updateCount = 0;
|
|
39
|
+
await cursor.eachAsync(async (doc) => {
|
|
40
|
+
i += 1;
|
|
41
|
+
const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
|
|
42
|
+
const version = event.workPerformed.version;
|
|
43
|
+
|
|
44
|
+
const alreadyMigrated = typeof version === 'string' && version.length > 0;
|
|
45
|
+
|
|
46
|
+
if (alreadyMigrated) {
|
|
47
|
+
console.log('alreadyMigrated.', event.project.id, event.id, event.startDate, version, i);
|
|
48
|
+
} else {
|
|
49
|
+
// 既存施設コンテンツバージョンを検索
|
|
50
|
+
const { maxVersion } = await eventRepo.aggregateScreeningEventMaxVersion({
|
|
51
|
+
project: { id: { $eq: event.project.id } },
|
|
52
|
+
workPerformed: { identifier: { $eq: event.workPerformed.identifier } },
|
|
53
|
+
location: { branchCode: { $in: [event.location.branchCode] } }
|
|
54
|
+
});
|
|
55
|
+
console.log('maxVersion:', maxVersion);
|
|
56
|
+
|
|
57
|
+
const newVersion: string = `${Number(maxVersion) + 1}`;
|
|
58
|
+
console.log('updating event...', event.project.id, event.id, event.startDate, newVersion, i);
|
|
59
|
+
await eventRepo.updatePartiallyById({
|
|
60
|
+
id: event.id,
|
|
61
|
+
attributes: <any>{
|
|
62
|
+
typeOf: event.typeOf,
|
|
63
|
+
'workPerformed.version': newVersion
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
updateCount += 1;
|
|
67
|
+
console.log('updated.', event.project.id, event.id, event.startDate, newVersion, i);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
console.log(i, 'events checked');
|
|
72
|
+
console.log(updateCount, 'events updated');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
main()
|
|
76
|
+
.then(() => {
|
|
77
|
+
console.log('success!');
|
|
78
|
+
})
|
|
79
|
+
.catch(console.error);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const movieTheater = await placeRepo.updateScreeningRoom(
|
|
14
|
+
{
|
|
15
|
+
typeOf: chevre.factory.placeType.ScreeningRoom,
|
|
16
|
+
branchCode: '01',
|
|
17
|
+
project: {
|
|
18
|
+
id: PROJECT_ID,
|
|
19
|
+
typeOf: chevre.factory.organizationType.Project
|
|
20
|
+
},
|
|
21
|
+
containedInPlace: {
|
|
22
|
+
branchCode: '001',
|
|
23
|
+
project: {
|
|
24
|
+
id: PROJECT_ID,
|
|
25
|
+
typeOf: chevre.factory.organizationType.Project
|
|
26
|
+
},
|
|
27
|
+
typeOf: chevre.factory.placeType.MovieTheater
|
|
28
|
+
},
|
|
29
|
+
name: {
|
|
30
|
+
ja: '東京タワー TOP DECK',
|
|
31
|
+
en: 'TokyoTower TOP DECK'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{}
|
|
35
|
+
);
|
|
36
|
+
console.log('place found', movieTheater);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main()
|
|
40
|
+
.then(console.log)
|
|
41
|
+
.catch(console.error);
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -850,19 +850,20 @@ class MongoRepository {
|
|
|
850
850
|
},
|
|
851
851
|
{
|
|
852
852
|
$project: {
|
|
853
|
-
workPerformed: '$workPerformed'
|
|
853
|
+
workPerformed: '$workPerformed',
|
|
854
|
+
version: { $toInt: '$workPerformed.version' }
|
|
854
855
|
}
|
|
855
856
|
},
|
|
856
857
|
{
|
|
857
858
|
$group: {
|
|
858
859
|
_id: '$typeOf',
|
|
859
|
-
maxVersion: { $max: '$
|
|
860
|
+
maxVersion: { $max: '$version' }
|
|
860
861
|
}
|
|
861
862
|
}
|
|
862
863
|
])
|
|
863
864
|
.exec();
|
|
864
865
|
const maxVersion = (aggregations.length > 0)
|
|
865
|
-
? (_a = aggregations.shift()) === null || _a === void 0 ? void 0 : _a.maxVersion
|
|
866
|
+
? String((_a = aggregations.shift()) === null || _a === void 0 ? void 0 : _a.maxVersion)
|
|
866
867
|
: '0';
|
|
867
868
|
return { maxVersion };
|
|
868
869
|
});
|
|
@@ -37,7 +37,7 @@ export declare class MongoRepository {
|
|
|
37
37
|
/**
|
|
38
38
|
* 施設を保管する
|
|
39
39
|
*/
|
|
40
|
-
saveMovieTheater(params: factory.place.movieTheater.
|
|
40
|
+
saveMovieTheater(params: factory.place.movieTheater.IPlaceWithoutScreeningRoom): Promise<factory.place.movieTheater.IPlaceWithoutScreeningRoom>;
|
|
41
41
|
saveMovieTheaterByBranchCode4coa(params: factory.place.movieTheater.IPlace): Promise<factory.place.movieTheater.IPlace>;
|
|
42
42
|
findMovieTheaterByBranchCode(params: {
|
|
43
43
|
project: {
|
|
@@ -58,12 +58,22 @@ export declare class MongoRepository {
|
|
|
58
58
|
*/
|
|
59
59
|
findById(params: {
|
|
60
60
|
id: string;
|
|
61
|
-
},
|
|
61
|
+
}, inclusion: string[], exclusion: string[]): Promise<factory.place.movieTheater.IPlace>;
|
|
62
62
|
deleteMovieTheaterById(params: {
|
|
63
63
|
id: string;
|
|
64
64
|
}): Promise<void>;
|
|
65
|
-
createScreeningRoom(screeningRoom: factory.place.screeningRoom.IPlace): Promise<
|
|
66
|
-
|
|
65
|
+
createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>): Promise<{
|
|
66
|
+
/**
|
|
67
|
+
* 施設ID
|
|
68
|
+
*/
|
|
69
|
+
id: string;
|
|
70
|
+
}>;
|
|
71
|
+
updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>, $unset: any): Promise<{
|
|
72
|
+
/**
|
|
73
|
+
* 施設ID
|
|
74
|
+
*/
|
|
75
|
+
id: string;
|
|
76
|
+
}>;
|
|
67
77
|
deleteScreeningRoom(screeningRoom: {
|
|
68
78
|
project: {
|
|
69
79
|
id: string;
|
|
@@ -78,7 +88,12 @@ export declare class MongoRepository {
|
|
|
78
88
|
*/
|
|
79
89
|
branchCode: string;
|
|
80
90
|
};
|
|
81
|
-
}): Promise<
|
|
91
|
+
}): Promise<{
|
|
92
|
+
/**
|
|
93
|
+
* 施設ID
|
|
94
|
+
*/
|
|
95
|
+
id: string;
|
|
96
|
+
}>;
|
|
82
97
|
createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace): Promise<void>;
|
|
83
98
|
updateScreeningRoomSection(screeningRoomSection: factory.place.screeningRoomSection.IPlace, $unset: any): Promise<void>;
|
|
84
99
|
searchScreeningRoomSections(searchConditions: factory.place.screeningRoomSection.ISearchConditions & {
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -221,7 +221,16 @@ class MongoRepository {
|
|
|
221
221
|
else {
|
|
222
222
|
// 上書き禁止属性を除外(2022-08-24~)
|
|
223
223
|
const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
|
|
224
|
-
doc = yield this.placeModel.findOneAndUpdate({ _id: params.id }, updateFields, {
|
|
224
|
+
doc = yield this.placeModel.findOneAndUpdate({ _id: params.id }, updateFields, {
|
|
225
|
+
upsert: false,
|
|
226
|
+
new: true,
|
|
227
|
+
projection: {
|
|
228
|
+
__v: 0,
|
|
229
|
+
createdAt: 0,
|
|
230
|
+
updatedAt: 0,
|
|
231
|
+
containsPlace: 0
|
|
232
|
+
}
|
|
233
|
+
})
|
|
225
234
|
.exec();
|
|
226
235
|
}
|
|
227
236
|
if (doc === null) {
|
|
@@ -292,12 +301,32 @@ class MongoRepository {
|
|
|
292
301
|
/**
|
|
293
302
|
* 施設取得
|
|
294
303
|
*/
|
|
295
|
-
findById(params,
|
|
304
|
+
findById(params,
|
|
305
|
+
// projection?: any
|
|
306
|
+
inclusion, exclusion) {
|
|
296
307
|
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
+
let projection = {};
|
|
309
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
310
|
+
inclusion.forEach((field) => {
|
|
311
|
+
projection[field] = 1;
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
projection = {
|
|
316
|
+
__v: 0,
|
|
317
|
+
createdAt: 0,
|
|
318
|
+
updatedAt: 0
|
|
319
|
+
};
|
|
320
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
321
|
+
exclusion.forEach((field) => {
|
|
322
|
+
projection[field] = 0;
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
297
326
|
const doc = yield this.placeModel.findOne({
|
|
298
327
|
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
299
328
|
_id: { $eq: params.id }
|
|
300
|
-
},
|
|
329
|
+
}, projection)
|
|
301
330
|
.exec();
|
|
302
331
|
if (doc === null) {
|
|
303
332
|
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
@@ -360,6 +389,7 @@ class MongoRepository {
|
|
|
360
389
|
if (doc === null) {
|
|
361
390
|
throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoom, ['branchCode']);
|
|
362
391
|
}
|
|
392
|
+
return doc.toObject();
|
|
363
393
|
});
|
|
364
394
|
}
|
|
365
395
|
updateScreeningRoom(screeningRoom, $unset) {
|
|
@@ -391,6 +421,7 @@ class MongoRepository {
|
|
|
391
421
|
if (doc === null) {
|
|
392
422
|
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
393
423
|
}
|
|
424
|
+
return doc.toObject();
|
|
394
425
|
});
|
|
395
426
|
}
|
|
396
427
|
deleteScreeningRoom(screeningRoom) {
|
|
@@ -403,11 +434,16 @@ class MongoRepository {
|
|
|
403
434
|
$pull: {
|
|
404
435
|
containsPlace: { branchCode: screeningRoom.branchCode }
|
|
405
436
|
}
|
|
437
|
+
}, {
|
|
438
|
+
projection: {
|
|
439
|
+
_id: 1
|
|
440
|
+
}
|
|
406
441
|
})
|
|
407
442
|
.exec();
|
|
408
443
|
if (doc === null) {
|
|
409
444
|
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
410
445
|
}
|
|
446
|
+
return doc.toObject();
|
|
411
447
|
});
|
|
412
448
|
}
|
|
413
449
|
createScreeningRoomSection(screeningRoomSection) {
|
|
@@ -103,6 +103,9 @@ export declare class MongoRepository {
|
|
|
103
103
|
}): Promise<import("mongodb").DeleteResult>;
|
|
104
104
|
countDelayedTasks(params: {
|
|
105
105
|
delayInSeconds: number;
|
|
106
|
+
name: {
|
|
107
|
+
$nin?: factory.taskName[];
|
|
108
|
+
};
|
|
106
109
|
}): Promise<number>;
|
|
107
110
|
aggregateTask(params: {
|
|
108
111
|
project?: {
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -427,10 +427,7 @@ class MongoRepository {
|
|
|
427
427
|
const runsAtLt = moment()
|
|
428
428
|
.add(-params.delayInSeconds, 'seconds')
|
|
429
429
|
.toDate();
|
|
430
|
-
return this.taskModel.count({
|
|
431
|
-
status: factory.taskStatus.Ready,
|
|
432
|
-
runsAt: { $lt: runsAtLt }
|
|
433
|
-
})
|
|
430
|
+
return this.taskModel.count(Object.assign({ status: factory.taskStatus.Ready, runsAt: { $lt: runsAtLt } }, (Array.isArray(params.name.$nin)) ? { name: { $nin: params.name.$nin } } : undefined))
|
|
434
431
|
.exec();
|
|
435
432
|
});
|
|
436
433
|
}
|
|
@@ -58,12 +58,14 @@ function findEntranceGates(params) {
|
|
|
58
58
|
try {
|
|
59
59
|
movieTheater = yield repos.place.findById({ id: params.event.superEvent.location.id },
|
|
60
60
|
// 不要な属性を取得しない
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
['hasEntranceGate'], []
|
|
62
|
+
// {
|
|
63
|
+
// containsPlace: 0,
|
|
64
|
+
// hasPOS: 0,
|
|
65
|
+
// offers: 0,
|
|
66
|
+
// parentOrganization: 0
|
|
67
|
+
// }
|
|
68
|
+
);
|
|
67
69
|
}
|
|
68
70
|
catch (error) {
|
|
69
71
|
let throwsError = true;
|
|
@@ -13,6 +13,7 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const categoryCode_1 = require("../../repo/categoryCode");
|
|
15
15
|
const creativeWork_1 = require("../../repo/creativeWork");
|
|
16
|
+
const place_1 = require("../../repo/place");
|
|
16
17
|
const product_1 = require("../../repo/product");
|
|
17
18
|
const task_1 = require("../../repo/task");
|
|
18
19
|
const settings_1 = require("../../settings");
|
|
@@ -25,6 +26,7 @@ function call(data) {
|
|
|
25
26
|
yield onResourceUpdated(data)({
|
|
26
27
|
categoryCode: new categoryCode_1.MongoRepository(connectionSettings.connection),
|
|
27
28
|
creativeWork: new creativeWork_1.MongoRepository(connectionSettings.connection),
|
|
29
|
+
place: new place_1.MongoRepository(connectionSettings.connection),
|
|
28
30
|
product: new product_1.MongoRepository(connectionSettings.connection),
|
|
29
31
|
task: new task_1.MongoRepository(connectionSettings.connection)
|
|
30
32
|
});
|
|
@@ -56,6 +58,13 @@ function onResourceUpdated(params) {
|
|
|
56
58
|
typeOf: params.typeOf
|
|
57
59
|
})(repos);
|
|
58
60
|
break;
|
|
61
|
+
case factory.placeType.MovieTheater:
|
|
62
|
+
yield createInformMovieTheaterTasks({
|
|
63
|
+
project: { id: params.project.id },
|
|
64
|
+
ids: params.id,
|
|
65
|
+
typeOf: params.typeOf
|
|
66
|
+
})(repos);
|
|
67
|
+
break;
|
|
59
68
|
default:
|
|
60
69
|
// no op
|
|
61
70
|
}
|
|
@@ -197,3 +206,70 @@ function createInformCategoryCodeTasks(params) {
|
|
|
197
206
|
}
|
|
198
207
|
});
|
|
199
208
|
}
|
|
209
|
+
function createInformMovieTheaterTasks(params) {
|
|
210
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
if (params.ids.length !== 1) {
|
|
212
|
+
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
213
|
+
}
|
|
214
|
+
const movieTheater = yield repos.place.findById({ id: params.ids[0] }, [
|
|
215
|
+
'additionalProperty',
|
|
216
|
+
'branchCode',
|
|
217
|
+
'hasEntranceGate',
|
|
218
|
+
'hasPOS',
|
|
219
|
+
'kanaName',
|
|
220
|
+
'name',
|
|
221
|
+
'parentOrganization',
|
|
222
|
+
'project',
|
|
223
|
+
'telephone',
|
|
224
|
+
'url',
|
|
225
|
+
'typeOf',
|
|
226
|
+
'containsPlace.branchCode',
|
|
227
|
+
'containsPlace.name',
|
|
228
|
+
'containsPlace.typeOf',
|
|
229
|
+
'containsPlace.additionalProperty',
|
|
230
|
+
'containsPlace.address'
|
|
231
|
+
], []);
|
|
232
|
+
if (movieTheater.project.id !== params.project.id) {
|
|
233
|
+
throw new factory.errors.Argument('project.id', 'project.id not matched');
|
|
234
|
+
}
|
|
235
|
+
const movieTheaters4inform = [movieTheater];
|
|
236
|
+
if (movieTheaters4inform.length > 0) {
|
|
237
|
+
const taskRunsAt = new Date();
|
|
238
|
+
const informTasks = [];
|
|
239
|
+
informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
|
|
240
|
+
var _a;
|
|
241
|
+
const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
242
|
+
movieTheaters4inform.forEach((movieTheater4inform) => {
|
|
243
|
+
var _a;
|
|
244
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
245
|
+
delete movieTheater4inform._id;
|
|
246
|
+
const informActionAttributes = {
|
|
247
|
+
agent: movieTheater4inform.project,
|
|
248
|
+
object: movieTheater4inform,
|
|
249
|
+
project: movieTheater4inform.project,
|
|
250
|
+
recipient: {
|
|
251
|
+
id: '',
|
|
252
|
+
name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
|
|
253
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
254
|
+
url: informUrl
|
|
255
|
+
},
|
|
256
|
+
typeOf: factory.actionType.InformAction
|
|
257
|
+
};
|
|
258
|
+
informTasks.push({
|
|
259
|
+
project: movieTheater4inform.project,
|
|
260
|
+
name: factory.taskName.TriggerWebhook,
|
|
261
|
+
status: factory.taskStatus.Ready,
|
|
262
|
+
runsAt: taskRunsAt,
|
|
263
|
+
remainingNumberOfTries: 10,
|
|
264
|
+
numberOfTried: 0,
|
|
265
|
+
executionResults: [],
|
|
266
|
+
data: informActionAttributes
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
if (informTasks.length > 0) {
|
|
271
|
+
yield repos.task.saveMany(informTasks, { emitImmediately: true });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.36",
|
|
13
13
|
"@cinerino/sdk": "3.157.0-alpha.12",
|
|
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.115"
|
|
121
121
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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 = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const aggregation = await eventRepo.aggregateScreeningEventMaxVersion({
|
|
15
|
-
project: { id: { $eq: project.id } },
|
|
16
|
-
workPerformed: { identifier: { $eq: '00001' } },
|
|
17
|
-
location: { branchCode: { $in: ['118', '203'] } }
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
console.log('result:', aggregation);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
main()
|
|
24
|
-
.then(() => {
|
|
25
|
-
console.log('success!');
|
|
26
|
-
})
|
|
27
|
-
.catch(console.error);
|