@chevre/domain 22.13.0-alpha.1 → 22.13.0-alpha.11
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/event/migrateEventIdentifier4ttts.ts +96 -0
- package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +191 -0
- package/lib/chevre/repo/event.d.ts +34 -6
- package/lib/chevre/repo/event.js +104 -22
- package/lib/chevre/service/event.d.ts +3 -33
- package/lib/chevre/service/event.js +0 -47
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +22 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +274 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.d.ts +15 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +116 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +63 -327
- package/package.json +2 -2
- package/example/src/chevre/cancelEvent.ts +0 -22
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = eventRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
// _id: { $eq: 'blwz44d0k' },
|
|
17
|
+
'project.id': { $eq: project.id }
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
_id: 1,
|
|
21
|
+
startDate: 1,
|
|
22
|
+
project: 1,
|
|
23
|
+
identifier: 1,
|
|
24
|
+
additionalProperty: 1,
|
|
25
|
+
typeOf: 1
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('events found');
|
|
29
|
+
|
|
30
|
+
let i = 0;
|
|
31
|
+
let updateCount = 0;
|
|
32
|
+
await cursor.eachAsync(async (doc) => {
|
|
33
|
+
i += 1;
|
|
34
|
+
const event: Pick<
|
|
35
|
+
chevre.factory.event.screeningEvent.IEvent,
|
|
36
|
+
'id' | 'identifier' | 'startDate' | 'project' | 'additionalProperty' | 'typeOf'
|
|
37
|
+
> = doc.toObject();
|
|
38
|
+
|
|
39
|
+
console.log(
|
|
40
|
+
'alreadyMigrated?', event.project.id, event.id, event.startDate, i);
|
|
41
|
+
const isValidProject = event.project.id.substring(0, 5) === 'ttts-';
|
|
42
|
+
if (!isValidProject) {
|
|
43
|
+
throw new Error(`${event.project.id} ${event.id} invalid project.`);
|
|
44
|
+
}
|
|
45
|
+
const eventIdentifier = event.identifier;
|
|
46
|
+
const oldEventId = event.additionalProperty?.find(({ name }) => name === 'oldEventId')?.value;
|
|
47
|
+
const tourNumber = event.additionalProperty?.find(({ name }) => name === 'tourNumber')?.value;
|
|
48
|
+
if (typeof oldEventId !== 'string' || oldEventId === '') {
|
|
49
|
+
throw new Error(`${event.project.id} ${event.id} oldEventId required: ${oldEventId}`);
|
|
50
|
+
}
|
|
51
|
+
if (typeof tourNumber !== 'string' || tourNumber === '') {
|
|
52
|
+
throw new Error(`${event.project.id} ${event.id} tourNumber required: ${tourNumber}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const alreadyMigrated = typeof eventIdentifier === 'string' && eventIdentifier === oldEventId;
|
|
56
|
+
|
|
57
|
+
if (alreadyMigrated) {
|
|
58
|
+
console.log(
|
|
59
|
+
'already migrated.', event.project.id, event.id, event.startDate, i);
|
|
60
|
+
} else {
|
|
61
|
+
console.log(
|
|
62
|
+
'updating... oldEventId:',
|
|
63
|
+
oldEventId, event.project.id, event.id, event.startDate, i);
|
|
64
|
+
await eventRepo.updatePartiallyById({
|
|
65
|
+
project: { id: event.project.id },
|
|
66
|
+
id: event.id,
|
|
67
|
+
attributes: {
|
|
68
|
+
typeOf: event.typeOf,
|
|
69
|
+
...{
|
|
70
|
+
identifier: oldEventId
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
updateCount += 1;
|
|
75
|
+
console.log(
|
|
76
|
+
'updated.',
|
|
77
|
+
event.project.id, event.id, event.startDate, i);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
console.log(i, 'events checked');
|
|
82
|
+
console.log(updateCount, 'events updated');
|
|
83
|
+
|
|
84
|
+
// await eventRepo.projectEventFields<chevre.factory.eventType.ScreeningEvent>(
|
|
85
|
+
// {
|
|
86
|
+
// project: { id: { $eq: project.id } },
|
|
87
|
+
// typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
88
|
+
// // id
|
|
89
|
+
// },
|
|
90
|
+
// ['identifier']
|
|
91
|
+
// );
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
main()
|
|
95
|
+
.then()
|
|
96
|
+
.catch(console.error);
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
|
+
import * as moment from 'moment-timezone';
|
|
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 ADDITIONAL_PROPERTY_NAME = 'sampleCreateId';
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const today = moment()
|
|
17
|
+
.tz('Asia/Tokyo')
|
|
18
|
+
.format('YYYY-MM-DD');
|
|
19
|
+
const identifier = `fromSamples:${moment()
|
|
20
|
+
.format('YYYY-MM-DD HH:mm')}`;
|
|
21
|
+
const settingEvent: chevre.factory.event.screeningEvent.IAttributes = {
|
|
22
|
+
identifier,
|
|
23
|
+
additionalProperty: [
|
|
24
|
+
{ name: ADDITIONAL_PROPERTY_NAME, value: identifier }
|
|
25
|
+
],
|
|
26
|
+
project: {
|
|
27
|
+
id: project.id,
|
|
28
|
+
typeOf: chevre.factory.organizationType.Project
|
|
29
|
+
},
|
|
30
|
+
organizer: {
|
|
31
|
+
id: '59d20831e53ebc2b4e774466'
|
|
32
|
+
},
|
|
33
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
34
|
+
name: {
|
|
35
|
+
en: 'pet IMAX2D',
|
|
36
|
+
ja: 'ペット IMAX2D'
|
|
37
|
+
},
|
|
38
|
+
doorTime: moment(`${today}T13:00:00Z`)
|
|
39
|
+
.toDate(),
|
|
40
|
+
startDate: moment(`${today}T13:00:00Z`)
|
|
41
|
+
.toDate(),
|
|
42
|
+
endDate: moment(`${today}T14:00:00Z`)
|
|
43
|
+
.toDate(),
|
|
44
|
+
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
45
|
+
location: {
|
|
46
|
+
typeOf: chevre.factory.placeType.ScreeningRoom,
|
|
47
|
+
branchCode: '70',
|
|
48
|
+
name: {
|
|
49
|
+
ja: 'シネマ7',
|
|
50
|
+
en: 'CINEMA7'
|
|
51
|
+
},
|
|
52
|
+
address: {
|
|
53
|
+
ja: '',
|
|
54
|
+
en: ''
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
superEvent: {
|
|
58
|
+
typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
59
|
+
id: 'al9s38bj6',
|
|
60
|
+
videoFormat: [
|
|
61
|
+
{
|
|
62
|
+
typeOf: '2D',
|
|
63
|
+
name: '2D'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
typeOf: 'IMAX',
|
|
67
|
+
name: 'IMAX'
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
soundFormat: [],
|
|
71
|
+
workPerformed: {
|
|
72
|
+
typeOf: chevre.factory.creativeWorkType.Movie,
|
|
73
|
+
identifier: '1622100',
|
|
74
|
+
id: '5bfb841d5a78d7948369980a',
|
|
75
|
+
name: {
|
|
76
|
+
en: 'Pet',
|
|
77
|
+
ja: 'ペット'
|
|
78
|
+
},
|
|
79
|
+
duration: 'PT2H3M'
|
|
80
|
+
},
|
|
81
|
+
location: {
|
|
82
|
+
typeOf: chevre.factory.placeType.MovieTheater,
|
|
83
|
+
id: '5bfb841d5a78d7948369979a',
|
|
84
|
+
branchCode: '118',
|
|
85
|
+
name: {
|
|
86
|
+
ja: 'シネモーション赤坂 ',
|
|
87
|
+
en: 'CineMotion Akasaka'
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
kanaName: 'ペット IMAX2D',
|
|
91
|
+
name: {
|
|
92
|
+
en: 'pet IMAX2D',
|
|
93
|
+
ja: 'ペット IMAX2D'
|
|
94
|
+
},
|
|
95
|
+
additionalProperty: [],
|
|
96
|
+
startDate: moment('2022-09-30T15:00:00.000Z')
|
|
97
|
+
.toDate(),
|
|
98
|
+
endDate: moment('2029-07-31T15:00:00.000Z')
|
|
99
|
+
.toDate(),
|
|
100
|
+
headline: {
|
|
101
|
+
ja: 'IMAX2D上映'
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
offers: {
|
|
105
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
106
|
+
eligibleQuantity: {
|
|
107
|
+
typeOf: 'QuantitativeValue',
|
|
108
|
+
unitCode: chevre.factory.unitCode.C62,
|
|
109
|
+
maxValue: 6
|
|
110
|
+
},
|
|
111
|
+
itemOffered: {
|
|
112
|
+
id: '655dc6b02cbb99d946cb6081',
|
|
113
|
+
name: {
|
|
114
|
+
ja: '通常興行カタログ(サブカタログ版)'
|
|
115
|
+
},
|
|
116
|
+
serviceOutput: {
|
|
117
|
+
typeOf: chevre.factory.reservationType.EventReservation,
|
|
118
|
+
reservedTicket: {
|
|
119
|
+
typeOf: 'Ticket',
|
|
120
|
+
ticketedSeat: {
|
|
121
|
+
typeOf: chevre.factory.placeType.Seat
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
typeOf: chevre.factory.product.ProductType.EventService,
|
|
126
|
+
availableChannel: {
|
|
127
|
+
typeOf: 'ServiceChannel',
|
|
128
|
+
serviceLocation: {
|
|
129
|
+
typeOf: chevre.factory.placeType.ScreeningRoom,
|
|
130
|
+
branchCode: '70',
|
|
131
|
+
name: {
|
|
132
|
+
ja: 'シネマ7',
|
|
133
|
+
en: 'CINEMA7'
|
|
134
|
+
},
|
|
135
|
+
containedInPlace: {
|
|
136
|
+
typeOf: chevre.factory.placeType.MovieTheater,
|
|
137
|
+
id: '5bfb841d5a78d7948369979a',
|
|
138
|
+
branchCode: '118',
|
|
139
|
+
name: {
|
|
140
|
+
ja: 'シネモーション赤坂 ',
|
|
141
|
+
en: 'CineMotion Akasaka'
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
seller: {
|
|
148
|
+
typeOf: chevre.factory.organizationType.Corporation,
|
|
149
|
+
id: '59d20831e53ebc2b4e774466',
|
|
150
|
+
name: {
|
|
151
|
+
ja: 'シネモーション赤坂',
|
|
152
|
+
en: 'CineMotion Akasaka'
|
|
153
|
+
},
|
|
154
|
+
makesOffer: [
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const createResult = await eventRepo.upsertManyScreeningEventByIdentifier(
|
|
161
|
+
[
|
|
162
|
+
{
|
|
163
|
+
$set: settingEvent,
|
|
164
|
+
$unset: {}
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
{ update: false }
|
|
168
|
+
);
|
|
169
|
+
// tslint:disable-next-line:no-null-keyword
|
|
170
|
+
console.dir(createResult, { depth: null });
|
|
171
|
+
|
|
172
|
+
const updateResult = await eventRepo.upsertManyScreeningEventByIdentifier(
|
|
173
|
+
[
|
|
174
|
+
{
|
|
175
|
+
$set: {
|
|
176
|
+
...settingEvent,
|
|
177
|
+
eventStatus: chevre.factory.eventStatusType.EventCancelled
|
|
178
|
+
},
|
|
179
|
+
$unset: {}
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
{ update: true }
|
|
183
|
+
);
|
|
184
|
+
// tslint:disable-next-line:no-null-keyword
|
|
185
|
+
console.dir(updateResult, { depth: null });
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
main()
|
|
190
|
+
.then()
|
|
191
|
+
.catch(console.error);
|
|
@@ -56,6 +56,9 @@ type IKeyOfProjection4minimizedEvent<T extends AvailableEventType> = T extends f
|
|
|
56
56
|
type IUnset<T extends AvailableEventType> = {
|
|
57
57
|
[key in keyof factory.event.IEvent<T>]?: 1;
|
|
58
58
|
};
|
|
59
|
+
export type ICreatingEvent4ttts = Pick<factory.event.IAttributes<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'name' | 'offers' | 'organizer' | 'project' | 'startDate' | 'superEvent' | 'typeOf'> & {
|
|
60
|
+
identifier: string;
|
|
61
|
+
};
|
|
59
62
|
/**
|
|
60
63
|
* イベントリポジトリ
|
|
61
64
|
*/
|
|
@@ -104,6 +107,26 @@ export declare class EventRepo {
|
|
|
104
107
|
id: string;
|
|
105
108
|
}[];
|
|
106
109
|
} | void>;
|
|
110
|
+
/**
|
|
111
|
+
* イベントコードをキーにして冪等置換
|
|
112
|
+
*/
|
|
113
|
+
upsertManyScreeningEventByIdentifier(params: {
|
|
114
|
+
$set: factory.event.screeningEvent.IAttributes & {
|
|
115
|
+
id?: never;
|
|
116
|
+
};
|
|
117
|
+
$unset: IUnset<factory.eventType.ScreeningEvent>;
|
|
118
|
+
}[], options: {
|
|
119
|
+
/**
|
|
120
|
+
* falseの場合setOnInsertのみ
|
|
121
|
+
* trueの場合setのみ
|
|
122
|
+
*/
|
|
123
|
+
update: boolean;
|
|
124
|
+
}): Promise<{
|
|
125
|
+
bulkWriteResult: BulkWriteResult;
|
|
126
|
+
modifiedEvents: {
|
|
127
|
+
id: string;
|
|
128
|
+
}[];
|
|
129
|
+
} | void>;
|
|
107
130
|
/**
|
|
108
131
|
* イベント部分更新
|
|
109
132
|
*/
|
|
@@ -128,15 +151,20 @@ export declare class EventRepo {
|
|
|
128
151
|
}): Promise<{
|
|
129
152
|
id: string;
|
|
130
153
|
}>;
|
|
131
|
-
|
|
154
|
+
/**
|
|
155
|
+
* sskts専用
|
|
156
|
+
*/
|
|
157
|
+
saveManyEvents(params: {
|
|
132
158
|
id: string;
|
|
133
|
-
attributes: factory.event.IAttributes<
|
|
134
|
-
$unset?: IUnset<
|
|
159
|
+
attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>;
|
|
160
|
+
$unset?: IUnset<factory.eventType.ScreeningEvent>;
|
|
135
161
|
upsert: boolean;
|
|
136
162
|
}[]): Promise<void>;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
163
|
+
/**
|
|
164
|
+
* tttsイベントを識別子によって冪等作成する
|
|
165
|
+
*/
|
|
166
|
+
saveEventByIdentifier4ttts(params: {
|
|
167
|
+
attributes: ICreatingEvent4ttts;
|
|
140
168
|
}): Promise<{
|
|
141
169
|
id: string;
|
|
142
170
|
}>;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -73,6 +73,10 @@ class EventRepo {
|
|
|
73
73
|
if (Array.isArray(idIn)) {
|
|
74
74
|
andConditions.push({ _id: { $in: idIn } });
|
|
75
75
|
}
|
|
76
|
+
const identifierIn = conditions.identifiers;
|
|
77
|
+
if (Array.isArray(identifierIn)) {
|
|
78
|
+
andConditions.push({ identifier: { $exists: true, $in: identifierIn } });
|
|
79
|
+
}
|
|
76
80
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
77
81
|
/* istanbul ignore else */
|
|
78
82
|
if (Array.isArray(conditions.eventStatuses)) {
|
|
@@ -130,16 +134,6 @@ class EventRepo {
|
|
|
130
134
|
if (Array.isArray(locationBranchCodeIn)) {
|
|
131
135
|
andConditions.push({ 'location.branchCode': { $exists: true, $in: locationBranchCodeIn } });
|
|
132
136
|
}
|
|
133
|
-
// discontinue(2024-09-30)
|
|
134
|
-
// const hasOfferCatalogIdEq = conditions.hasOfferCatalog?.id?.$eq;
|
|
135
|
-
// if (typeof hasOfferCatalogIdEq === 'string') {
|
|
136
|
-
// andConditions.push({
|
|
137
|
-
// 'hasOfferCatalog.id': {
|
|
138
|
-
// $exists: true,
|
|
139
|
-
// $eq: hasOfferCatalogIdEq
|
|
140
|
-
// }
|
|
141
|
-
// });
|
|
142
|
-
// }
|
|
143
137
|
const additionalPropertyElemMatch = (_l = conditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
144
138
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
145
139
|
andConditions.push({
|
|
@@ -482,6 +476,71 @@ class EventRepo {
|
|
|
482
476
|
}
|
|
483
477
|
});
|
|
484
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* イベントコードをキーにして冪等置換
|
|
481
|
+
*/
|
|
482
|
+
upsertManyScreeningEventByIdentifier(params, options) {
|
|
483
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
484
|
+
const { update } = options;
|
|
485
|
+
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
486
|
+
const bulkWriteOps = [];
|
|
487
|
+
const queryFilters = [];
|
|
488
|
+
if (Array.isArray(params)) {
|
|
489
|
+
params.forEach(({ $set, $unset }) => {
|
|
490
|
+
const { project, identifier } = $set;
|
|
491
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
492
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
493
|
+
}
|
|
494
|
+
// リソースのユニークネスを保証するfilter
|
|
495
|
+
const filter = {
|
|
496
|
+
'project.id': { $eq: project.id },
|
|
497
|
+
identifier: { $exists: true, $eq: identifier }
|
|
498
|
+
};
|
|
499
|
+
queryFilters.push({
|
|
500
|
+
'project.id': { $eq: project.id },
|
|
501
|
+
identifier: { $exists: true, $eq: identifier }
|
|
502
|
+
});
|
|
503
|
+
if (update === true) {
|
|
504
|
+
const { maximumPhysicalAttendeeCapacity, additionalProperty, eventStatus, location, name, superEvent, offers, doorTime, endDate, startDate } = $set;
|
|
505
|
+
const setFields = {
|
|
506
|
+
maximumPhysicalAttendeeCapacity, additionalProperty,
|
|
507
|
+
eventStatus, location, name, superEvent, offers,
|
|
508
|
+
doorTime, endDate, startDate
|
|
509
|
+
};
|
|
510
|
+
const updateOne = {
|
|
511
|
+
filter,
|
|
512
|
+
update: Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
|
|
513
|
+
upsert: false
|
|
514
|
+
};
|
|
515
|
+
bulkWriteOps.push({ updateOne });
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
const { id, coaInfo, description, maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation } = $set, setOnInsertFields = __rest($set, ["id", "coaInfo", "description", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation"]);
|
|
519
|
+
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { identifier, _id: uniqid() });
|
|
520
|
+
const updateOne = {
|
|
521
|
+
filter,
|
|
522
|
+
update: {
|
|
523
|
+
$setOnInsert: setOnInsert
|
|
524
|
+
},
|
|
525
|
+
upsert: true
|
|
526
|
+
};
|
|
527
|
+
bulkWriteOps.push({ updateOne });
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
if (bulkWriteOps.length > 0) {
|
|
532
|
+
const bulkWriteResult = yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
533
|
+
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
534
|
+
const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, {
|
|
535
|
+
_id: 0,
|
|
536
|
+
id: { $toString: '$_id' }
|
|
537
|
+
})
|
|
538
|
+
.lean()
|
|
539
|
+
.exec();
|
|
540
|
+
return { bulkWriteResult, modifiedEvents };
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
485
544
|
/**
|
|
486
545
|
* イベント部分更新
|
|
487
546
|
*/
|
|
@@ -553,6 +612,9 @@ class EventRepo {
|
|
|
553
612
|
return { id: savedEventId }; // optimize(2024-07-31~)
|
|
554
613
|
});
|
|
555
614
|
}
|
|
615
|
+
/**
|
|
616
|
+
* sskts専用
|
|
617
|
+
*/
|
|
556
618
|
saveManyEvents(params) {
|
|
557
619
|
return __awaiter(this, void 0, void 0, function* () {
|
|
558
620
|
const bulkWriteOps = [];
|
|
@@ -586,25 +648,45 @@ class EventRepo {
|
|
|
586
648
|
}
|
|
587
649
|
});
|
|
588
650
|
}
|
|
589
|
-
|
|
651
|
+
/**
|
|
652
|
+
* tttsイベントを識別子によって冪等作成する
|
|
653
|
+
*/
|
|
654
|
+
saveEventByIdentifier4ttts(params) {
|
|
590
655
|
return __awaiter(this, void 0, void 0, function* () {
|
|
591
|
-
//
|
|
592
|
-
const _a = params.attributes, {
|
|
656
|
+
// const { oldEventId } = params;
|
|
657
|
+
const _a = params.attributes, { project, typeOf, eventStatus, identifier, organizer } = _a, updateFields = __rest(_a, ["project", "typeOf", "eventStatus", "identifier", "organizer"]);
|
|
658
|
+
// const identifier = oldEventId;
|
|
659
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
660
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
661
|
+
}
|
|
593
662
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
594
663
|
const id = uniqid();
|
|
595
|
-
const doc = yield this.eventModel.findOneAndUpdate(
|
|
664
|
+
const doc = yield this.eventModel.findOneAndUpdate(
|
|
665
|
+
// 全イベントにidentifierを保証したので、additionalPropertyによるフィルターからidentifierによるフィルターへ変更(2025-09-05~)
|
|
666
|
+
// {
|
|
667
|
+
// 'project.id': { $eq: project.id },
|
|
668
|
+
// typeOf: { $eq: typeOf },
|
|
669
|
+
// // 追加特性をキーに更新
|
|
670
|
+
// additionalProperty: {
|
|
671
|
+
// $exists: true,
|
|
672
|
+
// $all: [{ name: 'oldEventId', value: identifier }]
|
|
673
|
+
// }
|
|
674
|
+
// },
|
|
675
|
+
{
|
|
596
676
|
'project.id': { $eq: project.id },
|
|
597
|
-
|
|
598
|
-
// 追加特性をキーに更新
|
|
599
|
-
additionalProperty: {
|
|
600
|
-
$exists: true,
|
|
601
|
-
$all: [{ name: 'oldEventId', value: params.oldEventId }]
|
|
602
|
-
}
|
|
677
|
+
identifier: { $exists: true, $eq: identifier }
|
|
603
678
|
},
|
|
604
679
|
// upsertの場合、createがありうるので属性を除外しない
|
|
605
680
|
{
|
|
606
|
-
$setOnInsert:
|
|
607
|
-
|
|
681
|
+
$setOnInsert: {
|
|
682
|
+
_id: id,
|
|
683
|
+
typeOf,
|
|
684
|
+
project,
|
|
685
|
+
eventStatus,
|
|
686
|
+
organizer,
|
|
687
|
+
identifier // イベントコードを必ず追加(2025-09-03~)
|
|
688
|
+
// ...(typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined
|
|
689
|
+
},
|
|
608
690
|
$set: updateFields
|
|
609
691
|
}, { upsert: true, new: true, projection: { _id: 1 } })
|
|
610
692
|
.lean()
|
|
@@ -9,10 +9,7 @@ import type { EventRepo } from '../repo/event';
|
|
|
9
9
|
import type { EventSeriesRepo } from '../repo/eventSeries';
|
|
10
10
|
import type { MovieTheaterRepo } from '../repo/place/movieTheater';
|
|
11
11
|
import type { ScreeningRoomRepo } from '../repo/place/screeningRoom';
|
|
12
|
-
import type { ProjectRepo } from '../repo/project';
|
|
13
12
|
import type { SellerRepo } from '../repo/seller';
|
|
14
|
-
import type { SettingRepo } from '../repo/setting';
|
|
15
|
-
import type { TaskRepo } from '../repo/task';
|
|
16
13
|
import * as factory from '../factory';
|
|
17
14
|
interface IImportFromCOAParams {
|
|
18
15
|
project: {
|
|
@@ -38,7 +35,7 @@ interface IImportFromCOAParams {
|
|
|
38
35
|
/**
|
|
39
36
|
* イベントをインポートする
|
|
40
37
|
*/
|
|
41
|
-
|
|
38
|
+
declare function importFromCOA(params: IImportFromCOAParams): (repos: {
|
|
42
39
|
action: ActionRepo;
|
|
43
40
|
categoryCode: CategoryCodeRepo;
|
|
44
41
|
creativeWork: CreativeWorkRepo;
|
|
@@ -49,13 +46,10 @@ export declare function importFromCOA(params: IImportFromCOAParams): (repos: {
|
|
|
49
46
|
seller: SellerRepo;
|
|
50
47
|
masterService: COA.service.Master;
|
|
51
48
|
}) => Promise<void>;
|
|
52
|
-
export declare function minimizeSuperEvent(params: {
|
|
53
|
-
superEvent: factory.event.screeningEventSeries.IEvent;
|
|
54
|
-
}): factory.event.screeningEvent.ISuperEvent;
|
|
55
49
|
/**
|
|
56
50
|
* COA情報からイベントIDを作成する
|
|
57
51
|
*/
|
|
58
|
-
|
|
52
|
+
declare function createScreeningEventIdFromCOA(params: {
|
|
59
53
|
theaterCode: string;
|
|
60
54
|
titleCode: string;
|
|
61
55
|
titleBranchNum: string;
|
|
@@ -63,28 +57,4 @@ export declare function createScreeningEventIdFromCOA(params: {
|
|
|
63
57
|
screenCode: string;
|
|
64
58
|
timeBegin: string;
|
|
65
59
|
}): string;
|
|
66
|
-
export
|
|
67
|
-
/**
|
|
68
|
-
* 旧イベントID
|
|
69
|
-
*/
|
|
70
|
-
oldEventId: string;
|
|
71
|
-
/**
|
|
72
|
-
* イベント属性
|
|
73
|
-
*/
|
|
74
|
-
attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>;
|
|
75
|
-
project: {
|
|
76
|
-
id: string;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* 更新者
|
|
80
|
-
*/
|
|
81
|
-
agent: factory.action.IParticipant;
|
|
82
|
-
}): (repos: {
|
|
83
|
-
action: ActionRepo;
|
|
84
|
-
event: EventRepo;
|
|
85
|
-
eventSeries: EventSeriesRepo;
|
|
86
|
-
project: ProjectRepo;
|
|
87
|
-
setting: SettingRepo;
|
|
88
|
-
task: TaskRepo;
|
|
89
|
-
}) => Promise<void>;
|
|
90
|
-
export {};
|
|
60
|
+
export { importFromCOA, createScreeningEventIdFromCOA };
|
|
@@ -10,17 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.importFromCOA = importFromCOA;
|
|
13
|
-
exports.minimizeSuperEvent = minimizeSuperEvent;
|
|
14
13
|
exports.createScreeningEventIdFromCOA = createScreeningEventIdFromCOA;
|
|
15
|
-
exports.updateEvent4ttts = updateEvent4ttts;
|
|
16
14
|
const createDebug = require("debug");
|
|
17
15
|
// @ts-ignore
|
|
18
16
|
const difference = require("lodash.difference");
|
|
19
17
|
// import { google } from 'googleapis';
|
|
20
18
|
const moment = require("moment-timezone");
|
|
21
19
|
const factory = require("../factory");
|
|
22
|
-
// import { Settings } from '../settings';
|
|
23
|
-
const onEventChanged_1 = require("./offer/onEventChanged");
|
|
24
20
|
const debug = createDebug('chevre-domain:service:event');
|
|
25
21
|
/**
|
|
26
22
|
* イベントをインポートする
|
|
@@ -858,46 +854,3 @@ function createScreeningRoomFromCOA(project, seller, screenFromCOA) {
|
|
|
858
854
|
parentOrganization: { id: seller.id, typeOf: factory.organizationType.Corporation }
|
|
859
855
|
};
|
|
860
856
|
}
|
|
861
|
-
function updateEvent4ttts(params) {
|
|
862
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
863
|
-
const actionAttributes = Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.actionType.UpdateAction, agent: params.agent, object: {
|
|
864
|
-
id: params.oldEventId,
|
|
865
|
-
typeOf: factory.eventType.ScreeningEvent
|
|
866
|
-
} }, {
|
|
867
|
-
// replacee: reservation,
|
|
868
|
-
// replacer: params.attributes, // $unsetもありうるのでいったん保留
|
|
869
|
-
targetCollection: {
|
|
870
|
-
id: params.oldEventId,
|
|
871
|
-
typeOf: factory.eventType.ScreeningEvent
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
const action = yield repos.action.start(actionAttributes);
|
|
875
|
-
let savedEvent;
|
|
876
|
-
try {
|
|
877
|
-
savedEvent = yield repos.event.save4ttts({
|
|
878
|
-
oldEventId: params.oldEventId,
|
|
879
|
-
attributes: params.attributes
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
catch (error) {
|
|
883
|
-
try {
|
|
884
|
-
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
885
|
-
}
|
|
886
|
-
catch (__) {
|
|
887
|
-
// 失敗したら仕方ない
|
|
888
|
-
}
|
|
889
|
-
throw error;
|
|
890
|
-
}
|
|
891
|
-
// アクション完了
|
|
892
|
-
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: savedEvent.id } });
|
|
893
|
-
yield (0, onEventChanged_1.onEventChanged)({
|
|
894
|
-
id: [savedEvent.id],
|
|
895
|
-
project: { id: params.project.id },
|
|
896
|
-
typeOf: factory.eventType.ScreeningEvent,
|
|
897
|
-
isNew: false,
|
|
898
|
-
useInform: true
|
|
899
|
-
})(repos
|
|
900
|
-
// スケジュールによるイベント作成ではendDateに変更がないのでpendingReservationsへの同期はひとまず必要なし
|
|
901
|
-
);
|
|
902
|
-
});
|
|
903
|
-
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ICreatingEvent4ttts } from '../../../../repo/event';
|
|
2
|
+
import type { ICustomerMember } from '../../../../repo/member';
|
|
3
|
+
import * as factory from '../../../../factory';
|
|
4
|
+
declare function tour2creatingEvent(tour: ITourBySchedule, movieTheater: Pick<factory.place.movieTheater.IPlace, 'id' | 'branchCode' | 'parentOrganization'>, screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>, existingApplicationMembers: {
|
|
5
|
+
member: ICustomerMember;
|
|
6
|
+
}[], maxValue: number, eventService: Pick<factory.product.IProduct, 'id' | 'name'> & {
|
|
7
|
+
id: string;
|
|
8
|
+
}, screeningEventSeries: Pick<factory.event.screeningEventSeries.IEvent, 'location' | 'additionalProperty' | 'description' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'name' | 'soundFormat' | 'startDate' | 'typeOf' | 'videoFormat' | 'workPerformed'>, project: {
|
|
9
|
+
id: string;
|
|
10
|
+
}): ICreatingEvent4ttts;
|
|
11
|
+
interface ITourBySchedule {
|
|
12
|
+
day: string;
|
|
13
|
+
start_time: string;
|
|
14
|
+
end_time?: never;
|
|
15
|
+
door_time: Date;
|
|
16
|
+
start_date: Date;
|
|
17
|
+
end_date: Date;
|
|
18
|
+
duration?: never;
|
|
19
|
+
tour_number: string;
|
|
20
|
+
}
|
|
21
|
+
declare function schedule2tours(settings: factory.schedule.IEventWithSchedule, createDate: Date): ITourBySchedule[];
|
|
22
|
+
export { tour2creatingEvent, schedule2tours };
|