@chevre/domain 22.3.0-alpha.11 → 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.
- package/lib/chevre/service/event.js +45 -16
- package/package.json +1 -1
|
@@ -92,7 +92,8 @@ function importFromCOA(params) {
|
|
|
92
92
|
try {
|
|
93
93
|
// イベント永続化
|
|
94
94
|
const processStart = process.hrtime.bigint();
|
|
95
|
-
const screeningEvents = yield saveScreeningEvents(Object.assign({
|
|
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);
|
|
96
97
|
savedScreeningEventsCount = screeningEvents.length;
|
|
97
98
|
// COAから削除されたイベントをキャンセル済ステータスへ変更
|
|
98
99
|
cancelledIds = yield cancelDeletedEvents({
|
|
@@ -212,6 +213,7 @@ function processUpdateMovieTheater(params) {
|
|
|
212
213
|
function saveScreeningEventSeries(params) {
|
|
213
214
|
// tslint:disable-next-line:max-func-body-length
|
|
214
215
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
const { importingIds } = params;
|
|
215
217
|
const project = params.project;
|
|
216
218
|
// COAから作品取得
|
|
217
219
|
const filmsFromCOA = yield repos.masterService.title({
|
|
@@ -259,21 +261,35 @@ function saveScreeningEventSeries(params) {
|
|
|
259
261
|
let savedEventsCount = 0;
|
|
260
262
|
// saveScreeningEventSeries:trueの場合のみ保管(2022-10-10~)
|
|
261
263
|
if (params.saveScreeningEventSeries === true) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
+
}
|
|
277
293
|
debug('saving', saveParams.length, 'ScreeningEventSeries...');
|
|
278
294
|
yield repos.eventSeries.upsertManyEventSeriesById4sskts(saveParams);
|
|
279
295
|
debug('saved', saveParams.length, 'ScreeningEventSeries');
|
|
@@ -370,6 +386,19 @@ function createScreeningEvents(params) {
|
|
|
370
386
|
'offers', 'additionalProperty'
|
|
371
387
|
]);
|
|
372
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
|
+
}
|
|
373
402
|
}
|
|
374
403
|
else {
|
|
375
404
|
screeningEventSerieses = [];
|
package/package.json
CHANGED