@chevre/domain 22.3.0-alpha.10 → 22.3.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.
|
@@ -20,13 +20,13 @@ async function main() {
|
|
|
20
20
|
const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
|
|
21
21
|
|
|
22
22
|
const coaAuthClient = new (await chevre.loadCOA()).auth.RefreshToken({
|
|
23
|
-
endpoint:
|
|
24
|
-
refreshToken:
|
|
23
|
+
endpoint: String(process.env.COA_ENDPOINT),
|
|
24
|
+
refreshToken: process.env.COA_REFRESH_TOKEN,
|
|
25
25
|
useFetch: true
|
|
26
26
|
});
|
|
27
27
|
const masterService = new (await chevre.loadCOA()).service.Master(
|
|
28
28
|
{
|
|
29
|
-
endpoint:
|
|
29
|
+
endpoint: String(process.env.COA_ENDPOINT),
|
|
30
30
|
auth: coaAuthClient
|
|
31
31
|
},
|
|
32
32
|
{ timeout: 20000 }
|
|
@@ -45,6 +45,7 @@ async function main() {
|
|
|
45
45
|
.toDate(),
|
|
46
46
|
saveMovieTheater: false,
|
|
47
47
|
saveScreeningEventSeries: false,
|
|
48
|
+
// saveScreeningEventSeries: true,
|
|
48
49
|
saveScreeningEventSeriesPeriodInMonth: 3
|
|
49
50
|
})({
|
|
50
51
|
action: actionRepo,
|
|
@@ -73,27 +73,27 @@ function importFromCOA(params) {
|
|
|
73
73
|
let cancelledIds = [];
|
|
74
74
|
let processTime;
|
|
75
75
|
try {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
let screeningEventSerieses;
|
|
77
|
+
if (params.saveScreeningEventSeries === true) {
|
|
78
|
+
const saveScreeningEventSeriesResult = yield saveScreeningEventSeries({
|
|
79
|
+
locationBranchCode: params.locationBranchCode,
|
|
80
|
+
movieTheater,
|
|
81
|
+
project: params.project,
|
|
82
|
+
saveScreeningEventSeries: params.saveScreeningEventSeries,
|
|
83
|
+
saveScreeningEventSeriesPeriodInMonth: params.saveScreeningEventSeriesPeriodInMonth,
|
|
84
|
+
seller: { id: seller.id }
|
|
85
|
+
})(repos);
|
|
86
|
+
screeningEventSerieses = saveScreeningEventSeriesResult.screeningEventSerieses;
|
|
87
|
+
savedScreeningEventSeriesCount = saveScreeningEventSeriesResult.savedEventsCount;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// 施設コンテンツを保管しない場合、DBから施設コンテンツを検索するので、ここでは何もしない(2024-09-09~)
|
|
91
|
+
}
|
|
85
92
|
try {
|
|
86
93
|
// イベント永続化
|
|
87
94
|
const processStart = process.hrtime.bigint();
|
|
88
|
-
const screeningEvents = yield saveScreeningEvents({
|
|
89
|
-
screeningRooms,
|
|
90
|
-
screeningEventSerieses: screeningEventSerieses,
|
|
91
|
-
project: params.project,
|
|
92
|
-
targetImportFrom: targetImportFrom.toDate(),
|
|
93
|
-
targetImportThrough: targetImportThrough.toDate(),
|
|
94
|
-
seller: { id: seller.id },
|
|
95
|
-
instrument
|
|
96
|
-
})(repos);
|
|
95
|
+
const screeningEvents = yield saveScreeningEvents(Object.assign({ movieTheater,
|
|
96
|
+
screeningRooms, project: params.project, targetImportFrom: targetImportFrom.toDate(), targetImportThrough: targetImportThrough.toDate(), seller: { id: seller.id }, instrument }, (Array.isArray(screeningEventSerieses)) ? { screeningEventSerieses } : undefined))(repos);
|
|
97
97
|
savedScreeningEventsCount = screeningEvents.length;
|
|
98
98
|
// COAから削除されたイベントをキャンセル済ステータスへ変更
|
|
99
99
|
cancelledIds = yield cancelDeletedEvents({
|
|
@@ -213,6 +213,7 @@ function processUpdateMovieTheater(params) {
|
|
|
213
213
|
function saveScreeningEventSeries(params) {
|
|
214
214
|
// tslint:disable-next-line:max-func-body-length
|
|
215
215
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
const { importingIds } = params;
|
|
216
217
|
const project = params.project;
|
|
217
218
|
// COAから作品取得
|
|
218
219
|
const filmsFromCOA = yield repos.masterService.title({
|
|
@@ -260,21 +261,35 @@ function saveScreeningEventSeries(params) {
|
|
|
260
261
|
let savedEventsCount = 0;
|
|
261
262
|
// saveScreeningEventSeries:trueの場合のみ保管(2022-10-10~)
|
|
262
263
|
if (params.saveScreeningEventSeries === true) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
264
|
+
let saveParams;
|
|
265
|
+
if (Array.isArray(importingIds) && importingIds.length > 0) {
|
|
266
|
+
saveParams = screeningEventSerieses
|
|
267
|
+
.filter((screeningEventSeries) => importingIds.includes(screeningEventSeries.id))
|
|
268
|
+
.map((screeningEventSeries) => {
|
|
269
|
+
return {
|
|
270
|
+
id: screeningEventSeries.id,
|
|
271
|
+
attributes: screeningEventSeries,
|
|
272
|
+
upsert: true
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
// 更新対象が無限に増えるのを防ぐためにstartDateでフィルター
|
|
278
|
+
const someMonthsAgo = moment()
|
|
279
|
+
.add(-COA_IMPORT_SCREENING_EVENT_SERIES_PERIOD_IN_MONTH, 'months');
|
|
280
|
+
saveParams = screeningEventSerieses
|
|
281
|
+
.filter((screeningEventSeries) => {
|
|
282
|
+
return moment(screeningEventSeries.startDate)
|
|
283
|
+
.isAfter(someMonthsAgo);
|
|
284
|
+
})
|
|
285
|
+
.map((screeningEventSeries) => {
|
|
286
|
+
return {
|
|
287
|
+
id: screeningEventSeries.id,
|
|
288
|
+
attributes: screeningEventSeries,
|
|
289
|
+
upsert: true
|
|
290
|
+
};
|
|
291
|
+
});
|
|
292
|
+
}
|
|
278
293
|
debug('saving', saveParams.length, 'ScreeningEventSeries...');
|
|
279
294
|
yield repos.eventSeries.upsertManyEventSeriesById4sskts(saveParams);
|
|
280
295
|
debug('saved', saveParams.length, 'ScreeningEventSeries');
|
|
@@ -327,8 +342,8 @@ function saveScreeningEvents(params) {
|
|
|
327
342
|
});
|
|
328
343
|
}
|
|
329
344
|
function createScreeningEvents(params) {
|
|
345
|
+
// tslint:disable-next-line:max-func-body-length
|
|
330
346
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
331
|
-
const screeningEventSerieses = params.screeningEventSerieses;
|
|
332
347
|
const project = params.project;
|
|
333
348
|
// COAからイベント取得;
|
|
334
349
|
const schedulesFromCOA = yield repos.masterService.schedule({
|
|
@@ -345,6 +360,50 @@ function createScreeningEvents(params) {
|
|
|
345
360
|
theaterCode: params.instrument.theaterCode,
|
|
346
361
|
kubunClass: '046'
|
|
347
362
|
});
|
|
363
|
+
let screeningEventSerieses;
|
|
364
|
+
if (Array.isArray(params.screeningEventSerieses)) {
|
|
365
|
+
screeningEventSerieses = params.screeningEventSerieses;
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
// 指定がなければDBから検索する(2024-09-09~)
|
|
369
|
+
const importingEventSeriesIds = [...new Set(schedulesFromCOA.map((scheduleFromCOA) => {
|
|
370
|
+
return createScreeningEventSeriesId({
|
|
371
|
+
theaterCode: params.instrument.theaterCode,
|
|
372
|
+
titleCode: scheduleFromCOA.titleCode,
|
|
373
|
+
titleBranchNum: scheduleFromCOA.titleBranchNum
|
|
374
|
+
});
|
|
375
|
+
}))];
|
|
376
|
+
debug('searching eventSeries... importingEventSeriesIds:', importingEventSeriesIds);
|
|
377
|
+
if (importingEventSeriesIds.length > 0) {
|
|
378
|
+
screeningEventSerieses = yield repos.eventSeries.projectEventSeriesFields({
|
|
379
|
+
id: { $in: importingEventSeriesIds },
|
|
380
|
+
project: { id: { $eq: params.project.id } }
|
|
381
|
+
}, [
|
|
382
|
+
'project', 'typeOf', 'eventStatus', 'identifier',
|
|
383
|
+
'name', 'kanaName', 'alternativeHeadline', 'location',
|
|
384
|
+
'organizer', 'videoFormat', 'soundFormat', 'workPerformed',
|
|
385
|
+
'duration', 'endDate', 'startDate', 'coaInfo',
|
|
386
|
+
'offers', 'additionalProperty'
|
|
387
|
+
]);
|
|
388
|
+
debug(screeningEventSerieses.length, 'screeningEventSerieses for importing events found.');
|
|
389
|
+
// 万が一未インポートの施設コンテンツがあれば強制的にインポート(2024-09-09~)
|
|
390
|
+
if (screeningEventSerieses.length < importingEventSeriesIds.length) {
|
|
391
|
+
const saveScreeningEventSeriesResult = yield saveScreeningEventSeries({
|
|
392
|
+
locationBranchCode: params.instrument.theaterCode,
|
|
393
|
+
movieTheater: params.movieTheater,
|
|
394
|
+
project: params.project,
|
|
395
|
+
saveScreeningEventSeries: true,
|
|
396
|
+
saveScreeningEventSeriesPeriodInMonth: 0,
|
|
397
|
+
seller: { id: params.seller.id },
|
|
398
|
+
importingIds: importingEventSeriesIds
|
|
399
|
+
})(repos);
|
|
400
|
+
screeningEventSerieses = saveScreeningEventSeriesResult.screeningEventSerieses;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
screeningEventSerieses = [];
|
|
405
|
+
}
|
|
406
|
+
}
|
|
348
407
|
// イベントごとに永続化トライ
|
|
349
408
|
const screeningEvents = [];
|
|
350
409
|
schedulesFromCOA.forEach((scheduleFromCOA) => {
|
package/package.json
CHANGED