@chevre/domain 20.1.0-alpha.37 → 20.1.0-alpha.39
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/migrateEventProjectAttributes.ts +57 -0
- package/lib/chevre/repo/event.d.ts +3 -0
- package/lib/chevre/repo/event.js +15 -0
- package/lib/chevre/repo/reservation.d.ts +5 -0
- package/lib/chevre/repo/reservation.js +13 -0
- package/lib/chevre/service/assetTransaction/reserve/factory.js +66 -48
- package/lib/chevre/service/reserve/confirmReservation.js +27 -16
- package/package.json +2 -2
- package/example/src/chevre/migrateEventAdditionalProperties.ts +0 -96
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
+
|
|
14
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = eventRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
20
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
21
|
+
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
22
|
+
startDate: {
|
|
23
|
+
$gte: moment()
|
|
24
|
+
.add(-1, 'month')
|
|
25
|
+
.toDate()
|
|
26
|
+
}
|
|
27
|
+
// _id: { $eq: 'al6aff83w' }
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
// _id: 1,
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
console.log('events found');
|
|
34
|
+
|
|
35
|
+
let i = 0;
|
|
36
|
+
let updateCount = 0;
|
|
37
|
+
await cursor.eachAsync(async (doc) => {
|
|
38
|
+
i += 1;
|
|
39
|
+
const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
|
|
40
|
+
|
|
41
|
+
const locationProjectId = (<any>event.location).project?.id;
|
|
42
|
+
if (typeof locationProjectId !== 'string') {
|
|
43
|
+
console.log('already deleted', event.id, event.startDate, event.project.id, i);
|
|
44
|
+
} else {
|
|
45
|
+
updateCount += 1;
|
|
46
|
+
console.log('deleting project...', event.id, event.startDate, event.project.id, i);
|
|
47
|
+
await eventRepo.deleteUnnecessaryProjectAttributesById({ id: event.id });
|
|
48
|
+
console.log('project deleted', event.id, event.startDate, event.project.id, i);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
console.log(i, 'events checked');
|
|
52
|
+
console.log(updateCount, 'events updated');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
main()
|
|
56
|
+
.then()
|
|
57
|
+
.catch(console.error);
|
|
@@ -106,4 +106,7 @@ export declare class MongoRepository {
|
|
|
106
106
|
}, update: IUpdateAggregateReservationParams | IUpdateAggregateUseActionsParams): Promise<factory.event.IEvent<T>>;
|
|
107
107
|
bulkWrite(bulkWriteOps: any[]): Promise<import("mongodb").BulkWriteOpResultObject>;
|
|
108
108
|
getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
|
|
109
|
+
deleteUnnecessaryProjectAttributesById(params: {
|
|
110
|
+
id: string;
|
|
111
|
+
}): Promise<void>;
|
|
109
112
|
}
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -649,5 +649,20 @@ class MongoRepository {
|
|
|
649
649
|
.sort({ startDate: factory.sortType.Descending })
|
|
650
650
|
.cursor();
|
|
651
651
|
}
|
|
652
|
+
deleteUnnecessaryProjectAttributesById(params) {
|
|
653
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
654
|
+
yield this.eventModel.updateOne({
|
|
655
|
+
_id: { $eq: params.id }
|
|
656
|
+
}, {
|
|
657
|
+
$unset: {
|
|
658
|
+
'location.project': 1,
|
|
659
|
+
'workPerformed.project': 1,
|
|
660
|
+
'superEvent.location.project': 1,
|
|
661
|
+
'superEvent.workPerformed.project': 1
|
|
662
|
+
}
|
|
663
|
+
})
|
|
664
|
+
.exec();
|
|
665
|
+
});
|
|
666
|
+
}
|
|
652
667
|
}
|
|
653
668
|
exports.MongoRepository = MongoRepository;
|
|
@@ -35,6 +35,11 @@ export declare class MongoRepository {
|
|
|
35
35
|
underName?: factory.reservation.IUnderName<T>;
|
|
36
36
|
reservedTicket?: factory.reservation.ITicket;
|
|
37
37
|
}): Promise<factory.reservation.IReservation<T>>;
|
|
38
|
+
confirmByReservationNumber(params: {
|
|
39
|
+
reservationNumber: string;
|
|
40
|
+
previousReservationStatus: factory.reservationStatusType;
|
|
41
|
+
underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
|
|
42
|
+
}): Promise<void>;
|
|
38
43
|
/**
|
|
39
44
|
* 予約取消
|
|
40
45
|
*/
|
|
@@ -911,6 +911,19 @@ class MongoRepository {
|
|
|
911
911
|
return doc.toObject();
|
|
912
912
|
});
|
|
913
913
|
}
|
|
914
|
+
confirmByReservationNumber(params) {
|
|
915
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
916
|
+
const conditions = {
|
|
917
|
+
reservationNumber: { $eq: String(params.reservationNumber) },
|
|
918
|
+
reservationStatus: { $eq: params.previousReservationStatus }
|
|
919
|
+
};
|
|
920
|
+
const update = Object.assign({ reservationStatus: factory.reservationStatusType.ReservationConfirmed, modifiedTime: new Date() }, (params.underName !== undefined) ? { underName: params.underName } : undefined
|
|
921
|
+
// ...(params.reservedTicket !== undefined) ? { reservedTicket: params.reservedTicket } : undefined
|
|
922
|
+
);
|
|
923
|
+
yield this.reservationModel.updateMany(conditions, update)
|
|
924
|
+
.exec();
|
|
925
|
+
});
|
|
926
|
+
}
|
|
914
927
|
/**
|
|
915
928
|
* 予約取消
|
|
916
929
|
*/
|
|
@@ -8,6 +8,7 @@ const moment = require("moment");
|
|
|
8
8
|
const factory = require("../../../factory");
|
|
9
9
|
const accountTransactionIdentifier_1 = require("../../../factory/accountTransactionIdentifier");
|
|
10
10
|
const price_1 = require("./factory/price");
|
|
11
|
+
const USE_RESERVATION_PACKAGE_AS_OBJECT = process.env.USE_RESERVATION_PACKAGE_AS_OBJECT === '1';
|
|
11
12
|
function createStartParams(params) {
|
|
12
13
|
var _a;
|
|
13
14
|
const reservationNumber = params.reservationNumber;
|
|
@@ -425,7 +426,9 @@ function createReservation(params) {
|
|
|
425
426
|
: undefined);
|
|
426
427
|
}
|
|
427
428
|
exports.createReservation = createReservation;
|
|
429
|
+
// tslint:disable-next-line:max-func-body-length
|
|
428
430
|
function createPotentialActions(params) {
|
|
431
|
+
var _a;
|
|
429
432
|
const transaction = params.transaction;
|
|
430
433
|
const reservationFor = transaction.object.reservationFor;
|
|
431
434
|
if (reservationFor === undefined) {
|
|
@@ -433,55 +436,70 @@ function createPotentialActions(params) {
|
|
|
433
436
|
}
|
|
434
437
|
// 予約アクション属性作成
|
|
435
438
|
const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
// eventReservation.underName = confirmingReservation.underName;
|
|
446
|
-
// eventReservation.reservedTicket.underName = confirmingReservation.underName;
|
|
447
|
-
// }
|
|
448
|
-
// if (confirmingReservation.reservedTicket !== undefined) {
|
|
449
|
-
// if (confirmingReservation.reservedTicket.issuedBy !== undefined) {
|
|
450
|
-
// eventReservation.reservedTicket.issuedBy = confirmingReservation.reservedTicket.issuedBy;
|
|
451
|
-
// }
|
|
452
|
-
// }
|
|
453
|
-
// }
|
|
454
|
-
// }
|
|
455
|
-
// purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
|
|
456
|
-
if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
|
|
457
|
-
const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
|
|
458
|
-
eventReservation.underName = ordre2reservationUnderNameResult.underName;
|
|
459
|
-
// 不要なので廃止(2022-12-19~)
|
|
460
|
-
// eventReservation.reservedTicket.underName = ordre2reservationUnderNameResult.underName;
|
|
461
|
-
eventReservation.reservedTicket.issuedBy = ordre2reservationUnderNameResult.issuedBy;
|
|
462
|
-
}
|
|
463
|
-
const acceptedOffer4reservation = (_b = transaction.object.acceptedOffer) === null || _b === void 0 ? void 0 : _b.find((o) => { var _a, _b; return ((_b = (_a = o.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.id) === reservation.id; });
|
|
464
|
-
const moneyTransfer = createMoneyTransferActions({
|
|
465
|
-
acceptedOffer: acceptedOffer4reservation,
|
|
466
|
-
reservation: eventReservation,
|
|
467
|
-
transaction: params.transaction
|
|
468
|
-
});
|
|
469
|
-
return {
|
|
470
|
-
project: transaction.project,
|
|
471
|
-
typeOf: factory.actionType.ReserveAction,
|
|
472
|
-
result: {},
|
|
473
|
-
object: eventReservation,
|
|
474
|
-
// プロジェクトに変更(2022-05-26~)
|
|
475
|
-
agent: transaction.project,
|
|
476
|
-
potentialActions: {
|
|
477
|
-
moneyTransfer: moneyTransfer
|
|
478
|
-
},
|
|
479
|
-
purpose: {
|
|
480
|
-
typeOf: transaction.typeOf,
|
|
481
|
-
id: transaction.id
|
|
439
|
+
let reserveActionAttributes = [];
|
|
440
|
+
if (pendingReservations.length > 0) {
|
|
441
|
+
// ReservationPackageに対応(2022-12-22~)
|
|
442
|
+
if (USE_RESERVATION_PACKAGE_AS_OBJECT) {
|
|
443
|
+
let underName;
|
|
444
|
+
// purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
|
|
445
|
+
if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
|
|
446
|
+
const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
|
|
447
|
+
underName = ordre2reservationUnderNameResult.underName;
|
|
482
448
|
}
|
|
483
|
-
|
|
484
|
-
|
|
449
|
+
const reservationPackage = {
|
|
450
|
+
reservationFor,
|
|
451
|
+
reservationNumber: pendingReservations[0].reservationNumber,
|
|
452
|
+
reservationStatus: pendingReservations[0].reservationStatus,
|
|
453
|
+
subReservation: pendingReservations,
|
|
454
|
+
underName,
|
|
455
|
+
typeOf: factory.reservationType.ReservationPackage
|
|
456
|
+
};
|
|
457
|
+
reserveActionAttributes = [{
|
|
458
|
+
project: transaction.project,
|
|
459
|
+
typeOf: factory.actionType.ReserveAction,
|
|
460
|
+
// result: {},
|
|
461
|
+
object: reservationPackage,
|
|
462
|
+
agent: transaction.project,
|
|
463
|
+
potentialActions: {
|
|
464
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
465
|
+
// TODO implement
|
|
466
|
+
moneyTransfer: []
|
|
467
|
+
},
|
|
468
|
+
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
469
|
+
}];
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
reserveActionAttributes = pendingReservations.map((reservation) => {
|
|
473
|
+
var _a, _b;
|
|
474
|
+
const eventReservation = Object.assign(Object.assign({}, reservation), { reservationFor });
|
|
475
|
+
// purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
|
|
476
|
+
if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
|
|
477
|
+
const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
|
|
478
|
+
eventReservation.underName = ordre2reservationUnderNameResult.underName;
|
|
479
|
+
// 不要なので廃止(2022-12-19~)
|
|
480
|
+
// eventReservation.reservedTicket.underName = ordre2reservationUnderNameResult.underName;
|
|
481
|
+
eventReservation.reservedTicket.issuedBy = ordre2reservationUnderNameResult.issuedBy;
|
|
482
|
+
}
|
|
483
|
+
const acceptedOffer4reservation = (_b = transaction.object.acceptedOffer) === null || _b === void 0 ? void 0 : _b.find((o) => { var _a, _b; return ((_b = (_a = o.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.id) === reservation.id; });
|
|
484
|
+
const moneyTransfer = createMoneyTransferActions({
|
|
485
|
+
acceptedOffer: acceptedOffer4reservation,
|
|
486
|
+
reservation: eventReservation,
|
|
487
|
+
transaction: params.transaction
|
|
488
|
+
});
|
|
489
|
+
return {
|
|
490
|
+
project: transaction.project,
|
|
491
|
+
typeOf: factory.actionType.ReserveAction,
|
|
492
|
+
// result: {},
|
|
493
|
+
object: eventReservation,
|
|
494
|
+
agent: transaction.project,
|
|
495
|
+
potentialActions: {
|
|
496
|
+
moneyTransfer: moneyTransfer
|
|
497
|
+
},
|
|
498
|
+
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
499
|
+
};
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}
|
|
485
503
|
return {
|
|
486
504
|
reserve: reserveActionAttributes
|
|
487
505
|
};
|
|
@@ -19,6 +19,7 @@ const onReservationConfirmed_1 = require("./potentialActions/onReservationConfir
|
|
|
19
19
|
* 予約を確定する
|
|
20
20
|
*/
|
|
21
21
|
function confirmReservation(actionAttributesList) {
|
|
22
|
+
// tslint:disable-next-line:max-func-body-length
|
|
22
23
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
24
|
let confirmedReservations = [];
|
|
24
25
|
if (actionAttributesList.length > 0) {
|
|
@@ -26,19 +27,31 @@ function confirmReservation(actionAttributesList) {
|
|
|
26
27
|
const reservation = actionAttributes.object;
|
|
27
28
|
const action = yield repos.action.start(actionAttributes);
|
|
28
29
|
try {
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
// ReservationPackageに対応(2022-12-22~)
|
|
31
|
+
if (reservation.typeOf === factory.reservationType.ReservationPackage) {
|
|
32
|
+
// 予約を確定状態に変更する
|
|
33
|
+
yield repos.reservation.confirmByReservationNumber({
|
|
34
|
+
reservationNumber: reservation.reservationNumber,
|
|
35
|
+
previousReservationStatus: reservation.reservationStatus,
|
|
36
|
+
underName: reservation.underName
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// 予約を確定状態に変更する
|
|
41
|
+
// reservation = await repos.reservation.confirm<factory.reservationType.EventReservation>({
|
|
42
|
+
yield repos.reservation.confirm({
|
|
43
|
+
// 更新属性をwhitelist化(2022-06-13~)
|
|
44
|
+
// ...actionAttributes.object,
|
|
45
|
+
id: reservation.id,
|
|
46
|
+
previousReservationStatus: reservation.reservationStatus,
|
|
47
|
+
underName: reservation.underName
|
|
48
|
+
// issuedThroughは予約取引開始時に確定しているので更新不要(2022-12-21~)
|
|
49
|
+
// reservedTicket: reservation.reservedTicket
|
|
50
|
+
});
|
|
51
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
52
|
+
// delete (<any>reservation)._id;
|
|
53
|
+
// confirmedReservations.push(reservation);
|
|
54
|
+
}
|
|
42
55
|
}
|
|
43
56
|
catch (error) {
|
|
44
57
|
// actionにエラー結果を追加
|
|
@@ -52,9 +65,7 @@ function confirmReservation(actionAttributesList) {
|
|
|
52
65
|
throw error;
|
|
53
66
|
}
|
|
54
67
|
// アクション完了
|
|
55
|
-
const actionResult = {
|
|
56
|
-
confirmedReservationId: reservation.id
|
|
57
|
-
};
|
|
68
|
+
const actionResult = {};
|
|
58
69
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
59
70
|
yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes)({ task: repos.task });
|
|
60
71
|
})));
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.280.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.280.0-alpha.9",
|
|
13
13
|
"@cinerino/sdk": "3.135.0-alpha.4",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.1.0-alpha.
|
|
123
|
+
"version": "20.1.0-alpha.39"
|
|
124
124
|
}
|
|
@@ -1,96 +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 = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
-
|
|
14
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
-
const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const cursor = eventRepo.getCursor(
|
|
18
|
-
{
|
|
19
|
-
// 'project.id': { $eq: project.id },
|
|
20
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
22
|
-
startDate: {
|
|
23
|
-
$gte: moment()
|
|
24
|
-
.add(-1, 'month')
|
|
25
|
-
.toDate()
|
|
26
|
-
}
|
|
27
|
-
// _id: { $eq: 'al6aff83w' }
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
// _id: 1,
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
console.log('events found');
|
|
34
|
-
|
|
35
|
-
const additionalPropertyNames: string[] = [];
|
|
36
|
-
const projectIds: string[] = [];
|
|
37
|
-
|
|
38
|
-
let i = 0;
|
|
39
|
-
let updateCount = 0;
|
|
40
|
-
await cursor.eachAsync(async (doc) => {
|
|
41
|
-
i += 1;
|
|
42
|
-
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
43
|
-
|
|
44
|
-
const additionalPropertyNamesOnEvent = event.additionalProperty?.map((p) => p.name);
|
|
45
|
-
if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
|
|
46
|
-
console.log(additionalPropertyNamesOnEvent.length, 'additionalPropertyNamesOnEvent found', event.startDate, event.project.id);
|
|
47
|
-
additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
|
|
48
|
-
projectIds.push(event.project.id);
|
|
49
|
-
additionalPropertyNamesOnEvent.forEach((name) => {
|
|
50
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
51
|
-
throw new Error(`not matched ${event.project.id} ${event.id}`);
|
|
52
|
-
}
|
|
53
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
54
|
-
if (name.length < 8) {
|
|
55
|
-
throw new Error(`length matched ${event.project.id} ${event.id} ${name}`);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
|
|
60
|
-
const existings = await additionalPropertyRepo.search({
|
|
61
|
-
project: { id: { $eq: event.project.id } },
|
|
62
|
-
limit: 1,
|
|
63
|
-
page: 1,
|
|
64
|
-
name: { $regex: `^${additionalPropertyNameOnEvent}$` },
|
|
65
|
-
inCodeSet: { identifier: { $eq: event.typeOf } }
|
|
66
|
-
});
|
|
67
|
-
if (existings.length > 0) {
|
|
68
|
-
console.log('already existed', additionalPropertyNameOnEvent, event.id, event.startDate, event.project.id);
|
|
69
|
-
} else {
|
|
70
|
-
updateCount += 1;
|
|
71
|
-
await additionalPropertyRepo.save({
|
|
72
|
-
attributes: {
|
|
73
|
-
project: event.project,
|
|
74
|
-
typeOf: 'CategoryCode',
|
|
75
|
-
codeValue: additionalPropertyNameOnEvent,
|
|
76
|
-
inCodeSet: {
|
|
77
|
-
typeOf: 'CategoryCodeSet',
|
|
78
|
-
identifier: <any>event.typeOf
|
|
79
|
-
},
|
|
80
|
-
name: { ja: additionalPropertyNameOnEvent }
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
console.log('created', additionalPropertyNameOnEvent, event.id, event.startDate, event.project.id);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
console.log(i, 'events checked');
|
|
89
|
-
console.log(updateCount, 'events updated');
|
|
90
|
-
console.log([...new Set(additionalPropertyNames)]);
|
|
91
|
-
console.log([...new Set(projectIds)]);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
main()
|
|
95
|
-
.then()
|
|
96
|
-
.catch(console.error);
|