@chevre/domain 21.4.0-alpha.11 → 21.4.0-alpha.13
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/cleanEventsByMovieTheater.ts +32 -0
- package/example/src/chevre/migrateEventOrganizer.ts +16 -4
- package/example/src/chevre/migrateScreeningRoomOrganizer.ts +91 -0
- package/lib/chevre/repo/event.d.ts +16 -0
- package/lib/chevre/repo/event.js +20 -0
- package/lib/chevre/repo/place.d.ts +53 -12
- package/lib/chevre/repo/place.js +66 -141
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -0
- package/package.json +1 -1
- package/example/src/chevre/findScreeningRoomsByBranchCode.ts +0 -27
- package/example/src/chevre/searchScreeningRooms.ts +0 -33
- package/example/src/chevre/syncScreeningRooms.ts +0 -21
- package/example/src/chevre/syncScreeningRoomsAll.ts +0 -41
- package/lib/chevre/service/task/syncScreeningRooms.d.ts +0 -7
- package/lib/chevre/service/task/syncScreeningRooms.js +0 -23
|
@@ -0,0 +1,32 @@
|
|
|
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 LOCATION_BRANCH_CODE = String(process.env.LOCATION_BRANCH_CODE);
|
|
9
|
+
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
10
|
+
|
|
11
|
+
// tslint:disable-next-line:max-func-body-length
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
let result = await eventRepo.deleteScreeningEventSeriesByMovieTheaterBranchCode({
|
|
18
|
+
project: { id: project.id },
|
|
19
|
+
location: { branchCode: LOCATION_BRANCH_CODE }
|
|
20
|
+
});
|
|
21
|
+
console.log('deleteScreeningEventSeriesByMovieTheaterBranchCode processed.', result);
|
|
22
|
+
|
|
23
|
+
result = await eventRepo.deleteScreeningEventsByMovieTheaterBranchCode({
|
|
24
|
+
project: { id: project.id },
|
|
25
|
+
location: { branchCode: LOCATION_BRANCH_CODE }
|
|
26
|
+
});
|
|
27
|
+
console.log('deleteScreeningEventsByMovieTheaterBranchCode processed.', result);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main()
|
|
31
|
+
.then()
|
|
32
|
+
.catch(console.error);
|
|
@@ -20,7 +20,7 @@ async function main() {
|
|
|
20
20
|
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
21
|
typeOf: {
|
|
22
22
|
$in: [
|
|
23
|
-
|
|
23
|
+
chevre.factory.eventType.ScreeningEvent,
|
|
24
24
|
chevre.factory.eventType.ScreeningEventSeries
|
|
25
25
|
]
|
|
26
26
|
},
|
|
@@ -63,12 +63,18 @@ async function main() {
|
|
|
63
63
|
console.log('already exist...', event.project.id, event.id, event.startDate, organizerId, i);
|
|
64
64
|
} else {
|
|
65
65
|
let movieTheaterId: string;
|
|
66
|
+
let movieTheaterBranchCode: string;
|
|
66
67
|
if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
|
|
67
68
|
movieTheaterId = event.location.id;
|
|
69
|
+
movieTheaterBranchCode = event.location.branchCode;
|
|
68
70
|
} else {
|
|
69
71
|
movieTheaterId = event.superEvent.location.id;
|
|
72
|
+
movieTheaterBranchCode = event.superEvent.location.branchCode;
|
|
70
73
|
}
|
|
71
|
-
const movieTheaters = <Pick<
|
|
74
|
+
const movieTheaters = <Pick<
|
|
75
|
+
chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
|
|
76
|
+
'parentOrganization' | 'branchCode'
|
|
77
|
+
>[]>
|
|
72
78
|
await placeRepo.searchMovieTheaters(
|
|
73
79
|
{
|
|
74
80
|
limit: 1,
|
|
@@ -76,12 +82,18 @@ async function main() {
|
|
|
76
82
|
project: { id: { $eq: event.project.id } },
|
|
77
83
|
id: { $eq: movieTheaterId }
|
|
78
84
|
},
|
|
79
|
-
['parentOrganization'],
|
|
85
|
+
['parentOrganization', 'branchCode'],
|
|
80
86
|
[]
|
|
81
87
|
);
|
|
82
88
|
const movieTheater = movieTheaters.shift();
|
|
83
89
|
const sellerId = movieTheater?.parentOrganization?.id;
|
|
84
|
-
console.log(
|
|
90
|
+
console.log(
|
|
91
|
+
'movieTheater found',
|
|
92
|
+
event.project.id, event.id, event.startDate, 'sellerId:', sellerId,
|
|
93
|
+
'movieTheaterId:', movieTheaterId,
|
|
94
|
+
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
95
|
+
i
|
|
96
|
+
);
|
|
85
97
|
// if (typeof sellerId !== 'string') {
|
|
86
98
|
// throw new Error('movieTheater not found');
|
|
87
99
|
// }
|
|
@@ -0,0 +1,91 @@
|
|
|
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, { autoIndex: true });
|
|
13
|
+
|
|
14
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = placeRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
20
|
+
typeOf: {
|
|
21
|
+
$in: [
|
|
22
|
+
chevre.factory.placeType.ScreeningRoom
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
// organizer: { $exists: false }
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
containsPlace: 0
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
console.log('places found');
|
|
32
|
+
|
|
33
|
+
let i = 0;
|
|
34
|
+
let updateCount = 0;
|
|
35
|
+
await cursor.eachAsync(async (doc) => {
|
|
36
|
+
i += 1;
|
|
37
|
+
const screeningRoom: chevre.factory.place.screeningRoom.IPlace = doc.toObject();
|
|
38
|
+
console.log(screeningRoom);
|
|
39
|
+
|
|
40
|
+
const organizerId = screeningRoom.parentOrganization?.id;
|
|
41
|
+
const alreadyMigrated = typeof organizerId === 'string';
|
|
42
|
+
|
|
43
|
+
if (alreadyMigrated) {
|
|
44
|
+
console.log('already exist...', screeningRoom.project.id, screeningRoom.branchCode, organizerId, i);
|
|
45
|
+
} else {
|
|
46
|
+
const movieTheaterId = screeningRoom.containedInPlace?.id;
|
|
47
|
+
if (typeof movieTheaterId !== 'string') {
|
|
48
|
+
throw new Error('containedInPlace?.id undefined');
|
|
49
|
+
}
|
|
50
|
+
const movieTheaters = <Pick<chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom, 'parentOrganization'>[]>
|
|
51
|
+
await placeRepo.searchMovieTheaters(
|
|
52
|
+
{
|
|
53
|
+
limit: 1,
|
|
54
|
+
page: 1,
|
|
55
|
+
project: { id: { $eq: screeningRoom.project.id } },
|
|
56
|
+
id: { $eq: movieTheaterId }
|
|
57
|
+
},
|
|
58
|
+
['parentOrganization'],
|
|
59
|
+
[]
|
|
60
|
+
);
|
|
61
|
+
const movieTheater = movieTheaters.shift();
|
|
62
|
+
const sellerId = movieTheater?.parentOrganization?.id;
|
|
63
|
+
console.log('movieTheater found', screeningRoom.project.id, screeningRoom.branchCode, 'sellerId:', sellerId, i);
|
|
64
|
+
// if (typeof sellerId !== 'string') {
|
|
65
|
+
// throw new Error('movieTheater not found');
|
|
66
|
+
// }
|
|
67
|
+
if (typeof sellerId === 'string') {
|
|
68
|
+
const newParentOrganization: chevre.factory.place.screeningRoom.IParentOrganization = {
|
|
69
|
+
id: sellerId,
|
|
70
|
+
typeOf: chevre.factory.organizationType.Corporation
|
|
71
|
+
};
|
|
72
|
+
console.log('updating room...', screeningRoom.project.id, screeningRoom.branchCode, i);
|
|
73
|
+
await placeRepo.addParentOrganization2ScreeningRoom({
|
|
74
|
+
project: screeningRoom.project,
|
|
75
|
+
branchCode: screeningRoom.branchCode,
|
|
76
|
+
containedInPlace: { branchCode: String(screeningRoom.containedInPlace?.branchCode) },
|
|
77
|
+
parentOrganization: newParentOrganization
|
|
78
|
+
});
|
|
79
|
+
updateCount += 1;
|
|
80
|
+
console.log('updated.', screeningRoom.project.id, screeningRoom.branchCode, i);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
console.log(i, 'rooms checked');
|
|
86
|
+
console.log(updateCount, 'rooms updated');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main()
|
|
90
|
+
.then()
|
|
91
|
+
.catch(console.error);
|
|
@@ -169,6 +169,22 @@ export declare class MongoRepository {
|
|
|
169
169
|
};
|
|
170
170
|
id: string;
|
|
171
171
|
}): Promise<void>;
|
|
172
|
+
deleteScreeningEventsByMovieTheaterBranchCode(params: {
|
|
173
|
+
project: {
|
|
174
|
+
id: string;
|
|
175
|
+
};
|
|
176
|
+
location: {
|
|
177
|
+
branchCode: string;
|
|
178
|
+
};
|
|
179
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
180
|
+
deleteScreeningEventSeriesByMovieTheaterBranchCode(params: {
|
|
181
|
+
project: {
|
|
182
|
+
id: string;
|
|
183
|
+
};
|
|
184
|
+
location: {
|
|
185
|
+
branchCode: string;
|
|
186
|
+
};
|
|
187
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
172
188
|
deleteByProject(params: {
|
|
173
189
|
project: {
|
|
174
190
|
id: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -850,6 +850,26 @@ class MongoRepository {
|
|
|
850
850
|
.exec();
|
|
851
851
|
});
|
|
852
852
|
}
|
|
853
|
+
deleteScreeningEventsByMovieTheaterBranchCode(params) {
|
|
854
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
855
|
+
return this.eventModel.deleteMany({
|
|
856
|
+
typeOf: { $eq: factory.eventType.ScreeningEvent },
|
|
857
|
+
'project.id': { $eq: params.project.id },
|
|
858
|
+
'superEvent.location.branchCode': { $exists: true, $eq: params.location.branchCode }
|
|
859
|
+
})
|
|
860
|
+
.exec();
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
deleteScreeningEventSeriesByMovieTheaterBranchCode(params) {
|
|
864
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
865
|
+
return this.eventModel.deleteMany({
|
|
866
|
+
typeOf: { $eq: factory.eventType.ScreeningEventSeries },
|
|
867
|
+
'project.id': { $eq: params.project.id },
|
|
868
|
+
'location.branchCode': { $exists: true, $eq: params.location.branchCode }
|
|
869
|
+
})
|
|
870
|
+
.exec();
|
|
871
|
+
});
|
|
872
|
+
}
|
|
853
873
|
deleteByProject(params) {
|
|
854
874
|
return __awaiter(this, void 0, void 0, function* () {
|
|
855
875
|
yield this.eventModel.deleteMany({
|
|
@@ -44,12 +44,18 @@ export declare class MongoRepository {
|
|
|
44
44
|
*/
|
|
45
45
|
searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions & {}, inclusion: string[], exclusion: string[]): Promise<factory.place.movieTheater.IPlaceWithoutScreeningRoom[]>;
|
|
46
46
|
deleteMovieTheaterById(params: {
|
|
47
|
+
project: {
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
47
50
|
id: string;
|
|
48
51
|
}): Promise<void>;
|
|
49
52
|
createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
|
|
50
53
|
containedInPlace: {
|
|
51
54
|
branchCode: string;
|
|
52
55
|
};
|
|
56
|
+
parentOrganization?: {
|
|
57
|
+
id?: string;
|
|
58
|
+
};
|
|
53
59
|
}): Promise<{
|
|
54
60
|
containedInPlace: {
|
|
55
61
|
/**
|
|
@@ -63,6 +69,9 @@ export declare class MongoRepository {
|
|
|
63
69
|
containedInPlace: {
|
|
64
70
|
branchCode: string;
|
|
65
71
|
};
|
|
72
|
+
parentOrganization?: {
|
|
73
|
+
id?: string;
|
|
74
|
+
};
|
|
66
75
|
}, $unset: any): Promise<{
|
|
67
76
|
containedInPlace: {
|
|
68
77
|
/**
|
|
@@ -72,6 +81,19 @@ export declare class MongoRepository {
|
|
|
72
81
|
};
|
|
73
82
|
typeOf: factory.placeType.ScreeningRoom;
|
|
74
83
|
}>;
|
|
84
|
+
addParentOrganization2ScreeningRoom(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'branchCode' | 'parentOrganization' | 'project'> & {
|
|
85
|
+
containedInPlace: {
|
|
86
|
+
branchCode: string;
|
|
87
|
+
};
|
|
88
|
+
}): Promise<{
|
|
89
|
+
containedInPlace: {
|
|
90
|
+
/**
|
|
91
|
+
* 施設ID
|
|
92
|
+
*/
|
|
93
|
+
id: string;
|
|
94
|
+
};
|
|
95
|
+
typeOf: factory.placeType.ScreeningRoom;
|
|
96
|
+
}>;
|
|
75
97
|
updateScreeningRoomsByContainedInPlaceId(screeningRoom: {
|
|
76
98
|
project: {
|
|
77
99
|
id: string;
|
|
@@ -82,6 +104,9 @@ export declare class MongoRepository {
|
|
|
82
104
|
project: {
|
|
83
105
|
id: string;
|
|
84
106
|
};
|
|
107
|
+
parentOrganization?: {
|
|
108
|
+
id?: string;
|
|
109
|
+
};
|
|
85
110
|
/**
|
|
86
111
|
* ルームコード
|
|
87
112
|
*/
|
|
@@ -112,7 +137,11 @@ export declare class MongoRepository {
|
|
|
112
137
|
id: string;
|
|
113
138
|
};
|
|
114
139
|
}): Promise<void>;
|
|
115
|
-
createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace
|
|
140
|
+
createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace & {
|
|
141
|
+
parentOrganization?: {
|
|
142
|
+
id?: string;
|
|
143
|
+
};
|
|
144
|
+
}): Promise<{
|
|
116
145
|
containedInPlace: {
|
|
117
146
|
/**
|
|
118
147
|
* 施設ID
|
|
@@ -128,6 +157,9 @@ export declare class MongoRepository {
|
|
|
128
157
|
branchCode: string;
|
|
129
158
|
};
|
|
130
159
|
};
|
|
160
|
+
parentOrganization?: {
|
|
161
|
+
id?: string;
|
|
162
|
+
};
|
|
131
163
|
}, $unset: any): Promise<{
|
|
132
164
|
containedInPlace: {
|
|
133
165
|
/**
|
|
@@ -146,6 +178,9 @@ export declare class MongoRepository {
|
|
|
146
178
|
project: {
|
|
147
179
|
id: string;
|
|
148
180
|
};
|
|
181
|
+
parentOrganization?: {
|
|
182
|
+
id?: string;
|
|
183
|
+
};
|
|
149
184
|
/**
|
|
150
185
|
* セクションコード
|
|
151
186
|
*/
|
|
@@ -173,6 +208,9 @@ export declare class MongoRepository {
|
|
|
173
208
|
}>;
|
|
174
209
|
searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>[]>;
|
|
175
210
|
findScreeningRoomsByBranchCode(params: {
|
|
211
|
+
project: {
|
|
212
|
+
id: string;
|
|
213
|
+
};
|
|
176
214
|
branchCode: {
|
|
177
215
|
$eq: string;
|
|
178
216
|
};
|
|
@@ -182,7 +220,11 @@ export declare class MongoRepository {
|
|
|
182
220
|
};
|
|
183
221
|
};
|
|
184
222
|
}): Promise<IScreeningRoomFoundByBranchCode>;
|
|
185
|
-
createSeat(seat: factory.place.seat.IPlace
|
|
223
|
+
createSeat(seat: factory.place.seat.IPlace & {
|
|
224
|
+
parentOrganization?: {
|
|
225
|
+
id?: string;
|
|
226
|
+
};
|
|
227
|
+
}): Promise<{
|
|
186
228
|
containedInPlace: {
|
|
187
229
|
/**
|
|
188
230
|
* 施設ID
|
|
@@ -201,6 +243,9 @@ export declare class MongoRepository {
|
|
|
201
243
|
};
|
|
202
244
|
};
|
|
203
245
|
};
|
|
246
|
+
parentOrganization?: {
|
|
247
|
+
id?: string;
|
|
248
|
+
};
|
|
204
249
|
}, $unset: any): Promise<{
|
|
205
250
|
containedInPlace: {
|
|
206
251
|
/**
|
|
@@ -215,6 +260,9 @@ export declare class MongoRepository {
|
|
|
215
260
|
project: {
|
|
216
261
|
id: string;
|
|
217
262
|
};
|
|
263
|
+
parentOrganization?: {
|
|
264
|
+
id?: string;
|
|
265
|
+
};
|
|
218
266
|
/**
|
|
219
267
|
* 座席コード
|
|
220
268
|
*/
|
|
@@ -246,16 +294,6 @@ export declare class MongoRepository {
|
|
|
246
294
|
};
|
|
247
295
|
typeOf: factory.placeType.ScreeningRoom;
|
|
248
296
|
}>;
|
|
249
|
-
syncScreeningRooms(__: {
|
|
250
|
-
/**
|
|
251
|
-
* 施設ID
|
|
252
|
-
*/
|
|
253
|
-
id: string;
|
|
254
|
-
/**
|
|
255
|
-
* 特定のルームのみ同期する場合、ルームコードを指定する
|
|
256
|
-
*/
|
|
257
|
-
screeningRoomBranchCode?: string;
|
|
258
|
-
}): Promise<void>;
|
|
259
297
|
unsetContainsPlaceFromMovieTheater(params: {
|
|
260
298
|
/**
|
|
261
299
|
* 施設ID
|
|
@@ -281,6 +319,9 @@ export declare class MongoRepository {
|
|
|
281
319
|
id: string;
|
|
282
320
|
}, projection?: any): Promise<factory.place.busStop.IPlace>;
|
|
283
321
|
deleteBusStopById(params: {
|
|
322
|
+
project: {
|
|
323
|
+
id: string;
|
|
324
|
+
};
|
|
284
325
|
id: string;
|
|
285
326
|
}): Promise<void>;
|
|
286
327
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -342,7 +342,8 @@ class MongoRepository {
|
|
|
342
342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
343
343
|
yield this.placeModel.findOneAndDelete({
|
|
344
344
|
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
345
|
-
_id: { $eq: params.id }
|
|
345
|
+
_id: { $eq: params.id },
|
|
346
|
+
'project.id': { $eq: params.project.id }
|
|
346
347
|
}, { projection: { _id: 1 } })
|
|
347
348
|
.exec()
|
|
348
349
|
.then((doc) => {
|
|
@@ -353,13 +354,12 @@ class MongoRepository {
|
|
|
353
354
|
});
|
|
354
355
|
}
|
|
355
356
|
createScreeningRoom(screeningRoom) {
|
|
357
|
+
var _a;
|
|
356
358
|
return __awaiter(this, void 0, void 0, function* () {
|
|
357
359
|
// 施設存在確認
|
|
358
|
-
const movieTheaterDoc = yield this.placeModel.findOne({
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
branchCode: { $eq: screeningRoom.containedInPlace.branchCode }
|
|
362
|
-
}, { _id: 1, typeOf: 1, branchCode: 1, name: 1, parentOrganization: 1 })
|
|
360
|
+
const movieTheaterDoc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: screeningRoom.project.id }, branchCode: { $eq: screeningRoom.containedInPlace.branchCode } }, (typeof ((_a = screeningRoom.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
361
|
+
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoom.parentOrganization.id } }
|
|
362
|
+
: undefined), { _id: 1, typeOf: 1, branchCode: 1, name: 1, parentOrganization: 1 })
|
|
363
363
|
.exec();
|
|
364
364
|
if (movieTheaterDoc === null) {
|
|
365
365
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
@@ -395,13 +395,11 @@ class MongoRepository {
|
|
|
395
395
|
});
|
|
396
396
|
}
|
|
397
397
|
updateScreeningRoom(screeningRoom, $unset) {
|
|
398
|
+
var _a;
|
|
398
399
|
return __awaiter(this, void 0, void 0, function* () {
|
|
399
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
|
|
403
|
-
branchCode: screeningRoom.branchCode
|
|
404
|
-
}, Object.assign(Object.assign(Object.assign(Object.assign({ name: screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
|
|
400
|
+
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoom.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode }, branchCode: screeningRoom.branchCode }, (typeof ((_a = screeningRoom.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
401
|
+
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoom.parentOrganization.id } }
|
|
402
|
+
: undefined), Object.assign(Object.assign(Object.assign(Object.assign({ name: screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
|
|
405
403
|
? { address: screeningRoom.address }
|
|
406
404
|
: undefined), (typeof screeningRoom.openSeatingAllowed === 'boolean')
|
|
407
405
|
? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
|
|
@@ -425,6 +423,26 @@ class MongoRepository {
|
|
|
425
423
|
return doc.toObject();
|
|
426
424
|
});
|
|
427
425
|
}
|
|
426
|
+
addParentOrganization2ScreeningRoom(screeningRoom) {
|
|
427
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
428
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
429
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
430
|
+
'project.id': { $eq: screeningRoom.project.id },
|
|
431
|
+
'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
|
|
432
|
+
branchCode: screeningRoom.branchCode
|
|
433
|
+
}, {
|
|
434
|
+
parentOrganization: screeningRoom.parentOrganization
|
|
435
|
+
}, {
|
|
436
|
+
new: true,
|
|
437
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
438
|
+
})
|
|
439
|
+
.exec();
|
|
440
|
+
if (doc === null) {
|
|
441
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
442
|
+
}
|
|
443
|
+
return doc.toObject();
|
|
444
|
+
});
|
|
445
|
+
}
|
|
428
446
|
updateScreeningRoomsByContainedInPlaceId(screeningRoom) {
|
|
429
447
|
var _a;
|
|
430
448
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -441,13 +459,11 @@ class MongoRepository {
|
|
|
441
459
|
});
|
|
442
460
|
}
|
|
443
461
|
deleteScreeningRoom(screeningRoom) {
|
|
462
|
+
var _a;
|
|
444
463
|
return __awaiter(this, void 0, void 0, function* () {
|
|
445
|
-
const doc = yield this.placeModel.findOneAndDelete({
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
|
|
449
|
-
branchCode: screeningRoom.branchCode
|
|
450
|
-
}, {
|
|
464
|
+
const doc = yield this.placeModel.findOneAndDelete(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoom.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode }, branchCode: screeningRoom.branchCode }, (typeof ((_a = screeningRoom.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
465
|
+
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoom.parentOrganization.id } }
|
|
466
|
+
: undefined), {
|
|
451
467
|
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
452
468
|
})
|
|
453
469
|
.exec();
|
|
@@ -469,6 +485,7 @@ class MongoRepository {
|
|
|
469
485
|
}
|
|
470
486
|
// tslint:disable-next-line:max-func-body-length
|
|
471
487
|
createScreeningRoomSection(screeningRoomSection) {
|
|
488
|
+
var _a;
|
|
472
489
|
return __awaiter(this, void 0, void 0, function* () {
|
|
473
490
|
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
474
491
|
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
@@ -479,11 +496,9 @@ class MongoRepository {
|
|
|
479
496
|
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
480
497
|
}
|
|
481
498
|
// 施設存在確認
|
|
482
|
-
let doc = yield this.placeModel.findOne({
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
branchCode: { $eq: movieTheater.branchCode }
|
|
486
|
-
}, { _id: 1 })
|
|
499
|
+
let doc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: screeningRoomSection.project.id }, branchCode: { $eq: movieTheater.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
500
|
+
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
|
|
501
|
+
: undefined), { _id: 1 })
|
|
487
502
|
.exec();
|
|
488
503
|
if (doc === null) {
|
|
489
504
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
@@ -515,6 +530,7 @@ class MongoRepository {
|
|
|
515
530
|
}
|
|
516
531
|
// tslint:disable-next-line:max-func-body-length
|
|
517
532
|
updateScreeningRoomSection(screeningRoomSection, $unset) {
|
|
533
|
+
var _a;
|
|
518
534
|
return __awaiter(this, void 0, void 0, function* () {
|
|
519
535
|
const screeningRoom = screeningRoomSection.containedInPlace;
|
|
520
536
|
if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
|
|
@@ -524,13 +540,9 @@ class MongoRepository {
|
|
|
524
540
|
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
525
541
|
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
526
542
|
}
|
|
527
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
531
|
-
branchCode: { $eq: screeningRoom.branchCode },
|
|
532
|
-
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
|
|
533
|
-
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
|
|
543
|
+
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoomSection.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode }, branchCode: { $eq: screeningRoom.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
544
|
+
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
|
|
545
|
+
: undefined), Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
|
|
534
546
|
? {
|
|
535
547
|
'containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
|
|
536
548
|
}
|
|
@@ -691,17 +703,14 @@ class MongoRepository {
|
|
|
691
703
|
});
|
|
692
704
|
}
|
|
693
705
|
deleteScreeningRoomSection(screeningRoomSection) {
|
|
706
|
+
var _a;
|
|
694
707
|
return __awaiter(this, void 0, void 0, function* () {
|
|
695
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
696
|
-
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
697
|
-
'project.id': { $eq: screeningRoomSection.project.id },
|
|
698
|
-
'containedInPlace.branchCode': {
|
|
708
|
+
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoomSection.project.id }, 'containedInPlace.branchCode': {
|
|
699
709
|
$exists: true,
|
|
700
710
|
$eq: screeningRoomSection.containedInPlace.containedInPlace.branchCode
|
|
701
|
-
},
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}, {
|
|
711
|
+
}, branchCode: { $eq: screeningRoomSection.containedInPlace.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
712
|
+
? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
|
|
713
|
+
: undefined), {
|
|
705
714
|
$pull: {
|
|
706
715
|
containsPlace: {
|
|
707
716
|
branchCode: screeningRoomSection.branchCode
|
|
@@ -885,12 +894,9 @@ class MongoRepository {
|
|
|
885
894
|
return __awaiter(this, void 0, void 0, function* () {
|
|
886
895
|
const matchStages = [
|
|
887
896
|
{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } },
|
|
888
|
-
{
|
|
889
|
-
|
|
890
|
-
}
|
|
891
|
-
{
|
|
892
|
-
$match: { branchCode: { $eq: params.branchCode.$eq } }
|
|
893
|
-
}
|
|
897
|
+
{ $match: { 'project.id': { $eq: params.project.id } } },
|
|
898
|
+
{ $match: { 'containedInPlace.id': { $exists: true, $eq: params.containedInPlace.id.$eq } } },
|
|
899
|
+
{ $match: { branchCode: { $eq: params.branchCode.$eq } } }
|
|
894
900
|
];
|
|
895
901
|
const aggregate = this.placeModel.aggregate([
|
|
896
902
|
// { $unwind: '$containsPlace' },
|
|
@@ -929,7 +935,7 @@ class MongoRepository {
|
|
|
929
935
|
}
|
|
930
936
|
// tslint:disable-next-line:max-func-body-length
|
|
931
937
|
createSeat(seat) {
|
|
932
|
-
var _a, _b;
|
|
938
|
+
var _a, _b, _c;
|
|
933
939
|
return __awaiter(this, void 0, void 0, function* () {
|
|
934
940
|
const screeningRoomSection = seat.containedInPlace;
|
|
935
941
|
if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
|
|
@@ -944,11 +950,9 @@ class MongoRepository {
|
|
|
944
950
|
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
945
951
|
}
|
|
946
952
|
// 施設存在確認
|
|
947
|
-
let doc = yield this.placeModel.findOne({
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
branchCode: { $eq: movieTheater.branchCode }
|
|
951
|
-
}, { _id: 1 })
|
|
953
|
+
let doc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: seat.project.id }, branchCode: { $eq: movieTheater.branchCode } }, (typeof ((_a = seat.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
954
|
+
? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
|
|
955
|
+
: undefined), { _id: 1 })
|
|
952
956
|
.exec();
|
|
953
957
|
if (doc === null) {
|
|
954
958
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
@@ -961,7 +965,7 @@ class MongoRepository {
|
|
|
961
965
|
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
|
|
962
966
|
}, {
|
|
963
967
|
$push: {
|
|
964
|
-
'containsPlace.$[screeningRoomSection].containsPlace': Object.assign(Object.assign({ typeOf: seat.typeOf, branchCode: seat.branchCode, additionalProperty: seat.additionalProperty }, (typeof ((
|
|
968
|
+
'containsPlace.$[screeningRoomSection].containsPlace': Object.assign(Object.assign({ typeOf: seat.typeOf, branchCode: seat.branchCode, additionalProperty: seat.additionalProperty }, (typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.ja) === 'string' || typeof ((_c = seat.name) === null || _c === void 0 ? void 0 : _c.en) === 'string') ? { name: seat.name } : undefined), (Array.isArray(seat.seatingType)) ? { seatingType: seat.seatingType } : undefined)
|
|
965
969
|
}
|
|
966
970
|
}, {
|
|
967
971
|
new: true,
|
|
@@ -983,7 +987,7 @@ class MongoRepository {
|
|
|
983
987
|
}
|
|
984
988
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
985
989
|
updateSeat(seat, $unset) {
|
|
986
|
-
var _a, _b;
|
|
990
|
+
var _a, _b, _c;
|
|
987
991
|
return __awaiter(this, void 0, void 0, function* () {
|
|
988
992
|
const screeningRoomSection = seat.containedInPlace;
|
|
989
993
|
if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
|
|
@@ -997,14 +1001,9 @@ class MongoRepository {
|
|
|
997
1001
|
if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
|
|
998
1002
|
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
999
1003
|
}
|
|
1000
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1001
|
-
|
|
1002
|
-
'
|
|
1003
|
-
'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
|
|
1004
|
-
branchCode: { $eq: screeningRoom.branchCode },
|
|
1005
|
-
'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode },
|
|
1006
|
-
'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode }
|
|
1007
|
-
}, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': seat.branchCode }, (typeof ((_a = seat.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.en) === 'string')
|
|
1004
|
+
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: seat.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode }, branchCode: { $eq: screeningRoom.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }, 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode } }, (typeof ((_a = seat.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
1005
|
+
? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
|
|
1006
|
+
: undefined), Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': seat.branchCode }, (typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.ja) === 'string' || typeof ((_c = seat.name) === null || _c === void 0 ? void 0 : _c.en) === 'string')
|
|
1008
1007
|
? {
|
|
1009
1008
|
'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
|
|
1010
1009
|
}
|
|
@@ -1234,18 +1233,14 @@ class MongoRepository {
|
|
|
1234
1233
|
});
|
|
1235
1234
|
}
|
|
1236
1235
|
deleteSeat(seat) {
|
|
1236
|
+
var _a;
|
|
1237
1237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1238
|
-
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1239
|
-
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
1240
|
-
'project.id': { $eq: seat.project.id },
|
|
1241
|
-
'containedInPlace.branchCode': {
|
|
1238
|
+
const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: seat.project.id }, 'containedInPlace.branchCode': {
|
|
1242
1239
|
$exists: true,
|
|
1243
1240
|
$eq: seat.containedInPlace.containedInPlace.containedInPlace.branchCode
|
|
1244
|
-
},
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode }
|
|
1248
|
-
}, {
|
|
1241
|
+
}, branchCode: { $eq: seat.containedInPlace.containedInPlace.branchCode }, 'containsPlace.branchCode': { $eq: seat.containedInPlace.branchCode }, 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode } }, (typeof ((_a = seat.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
1242
|
+
? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
|
|
1243
|
+
: undefined), {
|
|
1249
1244
|
$pull: {
|
|
1250
1245
|
'containsPlace.$[screeningRoomSection].containsPlace': {
|
|
1251
1246
|
branchCode: seat.branchCode
|
|
@@ -1265,77 +1260,6 @@ class MongoRepository {
|
|
|
1265
1260
|
return doc.toObject();
|
|
1266
1261
|
});
|
|
1267
1262
|
}
|
|
1268
|
-
// tslint:disable-next-line:prefer-function-over-method
|
|
1269
|
-
syncScreeningRooms(__) {
|
|
1270
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1271
|
-
return;
|
|
1272
|
-
// const movieTheater = <Pick<
|
|
1273
|
-
// factory.place.movieTheater.IPlace,
|
|
1274
|
-
// 'id' | 'branchCode' | 'name' | 'project' | 'typeOf' | 'containsPlace'
|
|
1275
|
-
// >>await this.placeModel.findOne({
|
|
1276
|
-
// _id: { $eq: params.id },
|
|
1277
|
-
// typeOf: { $eq: factory.placeType.MovieTheater }
|
|
1278
|
-
// })
|
|
1279
|
-
// .select({
|
|
1280
|
-
// _id: 1, branchCode: 1, name: 1, project: 1, typeOf: 1, containsPlace: 1
|
|
1281
|
-
// })
|
|
1282
|
-
// .exec()
|
|
1283
|
-
// .then((doc) => {
|
|
1284
|
-
// if (doc === null) {
|
|
1285
|
-
// throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
1286
|
-
// }
|
|
1287
|
-
// return doc.toObject();
|
|
1288
|
-
// });
|
|
1289
|
-
// let screeningRoomsFromMovieTheater = movieTheater.containsPlace;
|
|
1290
|
-
// if (typeof params.screeningRoomBranchCode === 'string' && params.screeningRoomBranchCode.length > 0) {
|
|
1291
|
-
// screeningRoomsFromMovieTheater = screeningRoomsFromMovieTheater.filter(
|
|
1292
|
-
// (place) => place.branchCode === params.screeningRoomBranchCode
|
|
1293
|
-
// );
|
|
1294
|
-
// }
|
|
1295
|
-
// const creatingScreeningRooms: ICreatingScreeningRoom[] = screeningRoomsFromMovieTheater.map((place) => {
|
|
1296
|
-
// return {
|
|
1297
|
-
// ...place,
|
|
1298
|
-
// containedInPlace: {
|
|
1299
|
-
// id: movieTheater.id,
|
|
1300
|
-
// typeOf: movieTheater.typeOf,
|
|
1301
|
-
// branchCode: movieTheater.branchCode,
|
|
1302
|
-
// name: movieTheater.name
|
|
1303
|
-
// },
|
|
1304
|
-
// containsPlace: (Array.isArray(place.containsPlace)) ? place.containsPlace : [],
|
|
1305
|
-
// project: movieTheater.project
|
|
1306
|
-
// };
|
|
1307
|
-
// });
|
|
1308
|
-
// debug('sync processing', creatingScreeningRooms.length, 'screeningRooms...', creatingScreeningRooms);
|
|
1309
|
-
// await Promise.all(creatingScreeningRooms.map(async (createScreeningRoom) => {
|
|
1310
|
-
// const { typeOf, project, branchCode, ...setFields } = createScreeningRoom;
|
|
1311
|
-
// if (typeof branchCode === 'string' && branchCode.length > 0) {
|
|
1312
|
-
// const upsertScreeningRoomResult = await this.placeModel.findOneAndUpdate(
|
|
1313
|
-
// {
|
|
1314
|
-
// typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
1315
|
-
// 'project.id': { $eq: createScreeningRoom.project.id },
|
|
1316
|
-
// 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
|
|
1317
|
-
// branchCode: { $eq: createScreeningRoom.branchCode }
|
|
1318
|
-
// },
|
|
1319
|
-
// {
|
|
1320
|
-
// $setOnInsert: {
|
|
1321
|
-
// typeOf: createScreeningRoom.typeOf,
|
|
1322
|
-
// project: createScreeningRoom.project,
|
|
1323
|
-
// branchCode: createScreeningRoom.branchCode
|
|
1324
|
-
// },
|
|
1325
|
-
// $set: setFields
|
|
1326
|
-
// },
|
|
1327
|
-
// {
|
|
1328
|
-
// upsert: true,
|
|
1329
|
-
// new: true,
|
|
1330
|
-
// projection: { _id: 1 }
|
|
1331
|
-
// }
|
|
1332
|
-
// )
|
|
1333
|
-
// .exec();
|
|
1334
|
-
// debug('screeningRoom upserted. upsertScreeningRoomResult:', upsertScreeningRoomResult);
|
|
1335
|
-
// }
|
|
1336
|
-
// }));
|
|
1337
|
-
});
|
|
1338
|
-
}
|
|
1339
1263
|
unsetContainsPlaceFromMovieTheater(params) {
|
|
1340
1264
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1341
1265
|
return this.placeModel.findOneAndUpdate({
|
|
@@ -1440,7 +1364,8 @@ class MongoRepository {
|
|
|
1440
1364
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1441
1365
|
yield this.placeModel.findOneAndDelete({
|
|
1442
1366
|
typeOf: { $eq: factory.placeType.BusStop },
|
|
1443
|
-
_id: { $eq: params.id }
|
|
1367
|
+
_id: { $eq: params.id },
|
|
1368
|
+
'project.id': { $eq: params.project.id }
|
|
1444
1369
|
})
|
|
1445
1370
|
.exec()
|
|
1446
1371
|
.then((doc) => {
|
|
@@ -80,6 +80,7 @@ function aggregateByEvent(params) {
|
|
|
80
80
|
movieTheaterId = String((_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
|
|
81
81
|
}
|
|
82
82
|
const screeningRoom = yield repos.place.findScreeningRoomsByBranchCode({
|
|
83
|
+
project: { id: event.project.id },
|
|
83
84
|
branchCode: { $eq: event.location.branchCode },
|
|
84
85
|
containedInPlace: { id: { $eq: movieTheaterId } }
|
|
85
86
|
});
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
|
-
|
|
9
|
-
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
10
|
-
|
|
11
|
-
const screeningRoom = await placeRepo.findScreeningRoomsByBranchCode({
|
|
12
|
-
branchCode: {
|
|
13
|
-
$eq: '20'
|
|
14
|
-
},
|
|
15
|
-
containedInPlace: {
|
|
16
|
-
id: {
|
|
17
|
-
$eq: '5bfb841d5a78d7948369979a'
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
console.log('room found', screeningRoom);
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
main()
|
|
26
|
-
.then(console.log)
|
|
27
|
-
.catch(console.error);
|
|
@@ -1,33 +0,0 @@
|
|
|
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 rooms = await placeRepo.searchScreeningRooms(
|
|
14
|
-
{
|
|
15
|
-
limit: 10,
|
|
16
|
-
page: 1,
|
|
17
|
-
$projection: { sectionCount: 1 }
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
console.log('place found', rooms);
|
|
21
|
-
const filteredRooms = rooms.filter((room) => typeof room.sectionCount === 'number' && room.sectionCount > 1);
|
|
22
|
-
console.log(filteredRooms.length, 'filteredRooms found');
|
|
23
|
-
|
|
24
|
-
const screeningRoom = await placeRepo.findScreeningRoomsByBranchCode({
|
|
25
|
-
branchCode: { $eq: rooms[0].branchCode },
|
|
26
|
-
containedInPlace: { id: { $eq: String(rooms[0].containedInPlace?.id) } }
|
|
27
|
-
});
|
|
28
|
-
console.log('screeningRoom found', screeningRoom);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
main()
|
|
32
|
-
.then(console.log)
|
|
33
|
-
.catch(console.error);
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
await placeRepo.syncScreeningRooms({
|
|
14
|
-
id: '60409176f60a46000a7a3787'
|
|
15
|
-
});
|
|
16
|
-
console.log('synced');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
main()
|
|
20
|
-
.then(console.log)
|
|
21
|
-
.catch(console.error);
|
|
@@ -1,41 +0,0 @@
|
|
|
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 cursor = placeRepo.getCursor(
|
|
14
|
-
{
|
|
15
|
-
typeOf: { $eq: chevre.factory.placeType.MovieTheater }
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
_id: 1,
|
|
19
|
-
name: 1,
|
|
20
|
-
project: 1,
|
|
21
|
-
typeOf: 1
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
console.log('places found');
|
|
25
|
-
|
|
26
|
-
let i = 0;
|
|
27
|
-
await cursor.eachAsync(async (doc) => {
|
|
28
|
-
i += 1;
|
|
29
|
-
const { id, name, project, typeOf } = <Pick<chevre.factory.place.movieTheater.IPlace, 'id' | 'name' | 'project' | 'typeOf'>>
|
|
30
|
-
doc.toObject();
|
|
31
|
-
|
|
32
|
-
console.log('syncing...', project.id, typeOf, id, name.ja, i);
|
|
33
|
-
await placeRepo.syncScreeningRooms({ id });
|
|
34
|
-
console.log('synced.', project.id, typeOf, id, name.ja, i);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
main()
|
|
40
|
-
.then(console.log)
|
|
41
|
-
.catch(console.error);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as factory from '../../factory';
|
|
2
|
-
import { IConnectionSettings } from '../task';
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
4
|
-
/**
|
|
5
|
-
* タスク実行関数
|
|
6
|
-
*/
|
|
7
|
-
export declare function call(data: factory.task.syncScreeningRooms.IData): IOperation<void>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.call = void 0;
|
|
13
|
-
const place_1 = require("../../repo/place");
|
|
14
|
-
/**
|
|
15
|
-
* タスク実行関数
|
|
16
|
-
*/
|
|
17
|
-
function call(data) {
|
|
18
|
-
return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const placeRepo = new place_1.MongoRepository(connectionSettings.connection);
|
|
20
|
-
yield placeRepo.syncScreeningRooms({ id: data.id });
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.call = call;
|