@chevre/domain 21.4.0-alpha.11 → 21.4.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/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 +22 -10
- package/lib/chevre/repo/place.js +27 -79
- 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,6 +44,9 @@ 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'> & {
|
|
@@ -72,6 +75,19 @@ export declare class MongoRepository {
|
|
|
72
75
|
};
|
|
73
76
|
typeOf: factory.placeType.ScreeningRoom;
|
|
74
77
|
}>;
|
|
78
|
+
addParentOrganization2ScreeningRoom(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'branchCode' | 'parentOrganization' | 'project'> & {
|
|
79
|
+
containedInPlace: {
|
|
80
|
+
branchCode: string;
|
|
81
|
+
};
|
|
82
|
+
}): Promise<{
|
|
83
|
+
containedInPlace: {
|
|
84
|
+
/**
|
|
85
|
+
* 施設ID
|
|
86
|
+
*/
|
|
87
|
+
id: string;
|
|
88
|
+
};
|
|
89
|
+
typeOf: factory.placeType.ScreeningRoom;
|
|
90
|
+
}>;
|
|
75
91
|
updateScreeningRoomsByContainedInPlaceId(screeningRoom: {
|
|
76
92
|
project: {
|
|
77
93
|
id: string;
|
|
@@ -173,6 +189,9 @@ export declare class MongoRepository {
|
|
|
173
189
|
}>;
|
|
174
190
|
searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>[]>;
|
|
175
191
|
findScreeningRoomsByBranchCode(params: {
|
|
192
|
+
project: {
|
|
193
|
+
id: string;
|
|
194
|
+
};
|
|
176
195
|
branchCode: {
|
|
177
196
|
$eq: string;
|
|
178
197
|
};
|
|
@@ -246,16 +265,6 @@ export declare class MongoRepository {
|
|
|
246
265
|
};
|
|
247
266
|
typeOf: factory.placeType.ScreeningRoom;
|
|
248
267
|
}>;
|
|
249
|
-
syncScreeningRooms(__: {
|
|
250
|
-
/**
|
|
251
|
-
* 施設ID
|
|
252
|
-
*/
|
|
253
|
-
id: string;
|
|
254
|
-
/**
|
|
255
|
-
* 特定のルームのみ同期する場合、ルームコードを指定する
|
|
256
|
-
*/
|
|
257
|
-
screeningRoomBranchCode?: string;
|
|
258
|
-
}): Promise<void>;
|
|
259
268
|
unsetContainsPlaceFromMovieTheater(params: {
|
|
260
269
|
/**
|
|
261
270
|
* 施設ID
|
|
@@ -281,6 +290,9 @@ export declare class MongoRepository {
|
|
|
281
290
|
id: string;
|
|
282
291
|
}, projection?: any): Promise<factory.place.busStop.IPlace>;
|
|
283
292
|
deleteBusStopById(params: {
|
|
293
|
+
project: {
|
|
294
|
+
id: string;
|
|
295
|
+
};
|
|
284
296
|
id: string;
|
|
285
297
|
}): Promise<void>;
|
|
286
298
|
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) => {
|
|
@@ -425,6 +426,26 @@ class MongoRepository {
|
|
|
425
426
|
return doc.toObject();
|
|
426
427
|
});
|
|
427
428
|
}
|
|
429
|
+
addParentOrganization2ScreeningRoom(screeningRoom) {
|
|
430
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
431
|
+
const doc = yield this.placeModel.findOneAndUpdate({
|
|
432
|
+
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
433
|
+
'project.id': { $eq: screeningRoom.project.id },
|
|
434
|
+
'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
|
|
435
|
+
branchCode: screeningRoom.branchCode
|
|
436
|
+
}, {
|
|
437
|
+
parentOrganization: screeningRoom.parentOrganization
|
|
438
|
+
}, {
|
|
439
|
+
new: true,
|
|
440
|
+
projection: { 'containedInPlace.id': 1, typeOf: 1 }
|
|
441
|
+
})
|
|
442
|
+
.exec();
|
|
443
|
+
if (doc === null) {
|
|
444
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
445
|
+
}
|
|
446
|
+
return doc.toObject();
|
|
447
|
+
});
|
|
448
|
+
}
|
|
428
449
|
updateScreeningRoomsByContainedInPlaceId(screeningRoom) {
|
|
429
450
|
var _a;
|
|
430
451
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -885,12 +906,9 @@ class MongoRepository {
|
|
|
885
906
|
return __awaiter(this, void 0, void 0, function* () {
|
|
886
907
|
const matchStages = [
|
|
887
908
|
{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } },
|
|
888
|
-
{
|
|
889
|
-
|
|
890
|
-
}
|
|
891
|
-
{
|
|
892
|
-
$match: { branchCode: { $eq: params.branchCode.$eq } }
|
|
893
|
-
}
|
|
909
|
+
{ $match: { 'project.id': { $eq: params.project.id } } },
|
|
910
|
+
{ $match: { 'containedInPlace.id': { $exists: true, $eq: params.containedInPlace.id.$eq } } },
|
|
911
|
+
{ $match: { branchCode: { $eq: params.branchCode.$eq } } }
|
|
894
912
|
];
|
|
895
913
|
const aggregate = this.placeModel.aggregate([
|
|
896
914
|
// { $unwind: '$containsPlace' },
|
|
@@ -1265,77 +1283,6 @@ class MongoRepository {
|
|
|
1265
1283
|
return doc.toObject();
|
|
1266
1284
|
});
|
|
1267
1285
|
}
|
|
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
1286
|
unsetContainsPlaceFromMovieTheater(params) {
|
|
1340
1287
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1341
1288
|
return this.placeModel.findOneAndUpdate({
|
|
@@ -1440,7 +1387,8 @@ class MongoRepository {
|
|
|
1440
1387
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1441
1388
|
yield this.placeModel.findOneAndDelete({
|
|
1442
1389
|
typeOf: { $eq: factory.placeType.BusStop },
|
|
1443
|
-
_id: { $eq: params.id }
|
|
1390
|
+
_id: { $eq: params.id },
|
|
1391
|
+
'project.id': { $eq: params.project.id }
|
|
1444
1392
|
})
|
|
1445
1393
|
.exec()
|
|
1446
1394
|
.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;
|