@chevre/domain 23.2.0-alpha.4 → 23.2.0-alpha.40
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/importEventsFromCOAByTitle.ts +1 -1
- package/example/src/chevre/eventSeries/migrateEventSeriesOffers.ts +75 -0
- package/example/src/chevre/eventSeries/migrateEventSeriesVideoFormat.ts +80 -0
- package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -42
- package/example/src/chevre/{upsertOfferCatalogItemsByIdentifier.ts → offerCatalog/upsertOfferCatalogItemsByIdentifier.ts} +3 -3
- package/example/src/chevre/{upsertOfferCatalogsByIdentifier.ts → offerCatalog/upsertOfferCatalogsByIdentifier.ts} +4 -3
- package/example/src/chevre/place/adminEntranceGates.ts +69 -0
- package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
- package/example/src/chevre/place/findRooms.ts +24 -0
- package/example/src/chevre/place/findSections.ts +28 -0
- package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
- package/example/src/chevre/place/seatsJson2csv.ts +63 -0
- package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
- package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
- package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +49 -0
- package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
- package/example/src/chevre/roles/addAdminMovieTheaterReadPermissionIfNotExists.ts +34 -0
- package/example/src/chevre/roles/addAdminMovieTheaterWritePermissionIfNotExists.ts +34 -0
- package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
- package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
- package/lib/chevre/factory/event.js +5 -5
- package/lib/chevre/repo/aggregateOrder.js +0 -93
- package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
- package/lib/chevre/repo/aggregateReservation.js +0 -2
- package/lib/chevre/repo/creativeWork.js +9 -5
- package/lib/chevre/repo/event.d.ts +2 -2
- package/lib/chevre/repo/event.js +20 -8
- package/lib/chevre/repo/eventOffer.d.ts +8 -0
- package/lib/chevre/repo/eventOffer.js +11 -0
- package/lib/chevre/repo/eventSeries.d.ts +10 -4
- package/lib/chevre/repo/eventSeries.js +56 -28
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.js +10 -9
- package/lib/chevre/repo/mongoose/schemas/eventSeries.js +10 -0
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
- package/lib/chevre/repo/offerCatalog.d.ts +6 -1
- package/lib/chevre/repo/offerCatalog.js +26 -17
- package/lib/chevre/repo/offerCatalogItem.d.ts +6 -1
- package/lib/chevre/repo/offerCatalogItem.js +24 -15
- package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
- package/lib/chevre/repo/place/entranceGate.js +172 -0
- package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
- package/lib/chevre/repo/place/movieTheater.js +77 -6
- package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
- package/lib/chevre/repo/place/screeningRoom.js +227 -135
- package/lib/chevre/repo/place/seat.d.ts +47 -45
- package/lib/chevre/repo/place/seat.js +175 -45
- package/lib/chevre/repo/place/section.d.ts +60 -30
- package/lib/chevre/repo/place/section.js +337 -127
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repository.d.ts +8 -0
- package/lib/chevre/repository.js +16 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +6 -3
- package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
- package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
- package/lib/chevre/service/event/saveScreeningEvents.d.ts +1 -1
- package/lib/chevre/service/event/saveScreeningEvents.js +6 -5
- package/lib/chevre/service/offer/event/authorize/factory.js +4 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
- package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
- package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +4 -13
- package/lib/chevre/service/offer/onEventChanged.js +7 -5
- package/lib/chevre/service/offer.d.ts +5 -0
- package/lib/chevre/service/offer.js +34 -9
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +1 -1
- package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
- package/lib/chevre/service/task/onResourceDeleted.js +60 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +3 -7
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +19 -7
- package/lib/chevre/service/task/onResourceUpdated.js +206 -42
- package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -1
- package/lib/chevre/service/taskHandler.js +1 -0
- package/package.json +4 -3
- package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
- package/example/src/chevre/offers/createSampleOffers.ts +0 -154
- package/lib/chevre/service/eventOld.d.ts +0 -60
- package/lib/chevre/service/eventOld.js +0 -864
|
@@ -67,7 +67,7 @@ async function main() {
|
|
|
67
67
|
}
|
|
68
68
|
console.log('movieTheater:', movieTheater);
|
|
69
69
|
|
|
70
|
-
const screeningRooms = await roomRepo.
|
|
70
|
+
const screeningRooms = await roomRepo.findRooms({
|
|
71
71
|
project: { id: { $eq: project.id } },
|
|
72
72
|
containedInPlace: { branchCode: { $eq: movieTheater.branchCode } },
|
|
73
73
|
branchCode: { $eq: roomCode }
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const cursor = eventSeriesRepo.getCursor(
|
|
14
|
+
{
|
|
15
|
+
// _id: { $eq: 'bmd7x21f2' },
|
|
16
|
+
// 'project.id': { $eq: 'xxx' },
|
|
17
|
+
'offers.typeOf': {
|
|
18
|
+
$exists: true,
|
|
19
|
+
$eq: chevre.factory.offerType.AggregateOffer
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
// _id: 1,
|
|
24
|
+
// offers: 1,
|
|
25
|
+
// startDate: 1,
|
|
26
|
+
// project: 1,
|
|
27
|
+
// typeOf: 1
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
console.log('docs found');
|
|
31
|
+
|
|
32
|
+
let i = 0;
|
|
33
|
+
let updateCount = 0;
|
|
34
|
+
await cursor.eachAsync(async (doc) => {
|
|
35
|
+
i += 1;
|
|
36
|
+
const eventSeries: Pick<
|
|
37
|
+
chevre.factory.eventSeries.IEvent,
|
|
38
|
+
'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
|
|
39
|
+
> = doc.toObject();
|
|
40
|
+
|
|
41
|
+
console.log(
|
|
42
|
+
'alreadyMigrated?', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
43
|
+
const alreadyMigrated = eventSeries.offers?.typeOf === chevre.factory.offerType.Offer;
|
|
44
|
+
|
|
45
|
+
if (alreadyMigrated) {
|
|
46
|
+
console.log(
|
|
47
|
+
'already migrated.', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
48
|
+
} else {
|
|
49
|
+
console.log(
|
|
50
|
+
'updating...',
|
|
51
|
+
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
52
|
+
await eventSeriesRepo.saveEventSeries({
|
|
53
|
+
id: eventSeries.id,
|
|
54
|
+
attributes: <any>{
|
|
55
|
+
...{
|
|
56
|
+
typeOf: eventSeries.typeOf,
|
|
57
|
+
'offers.typeOf': chevre.factory.offerType.Offer
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
updateCount += 1;
|
|
62
|
+
console.log(
|
|
63
|
+
'updated.',
|
|
64
|
+
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(i, 'docs checked');
|
|
70
|
+
console.log(updateCount, 'docs updated');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main()
|
|
74
|
+
.then()
|
|
75
|
+
.catch(console.error);
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const cursor = eventSeriesRepo.getCursor(
|
|
14
|
+
{
|
|
15
|
+
// _id: { $eq: 'al9s38bj6' },
|
|
16
|
+
'project.id': { $nin: ['sskts-development', 'sskts-test', 'sskts-production'] }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
// _id: 1,
|
|
20
|
+
// offers: 1,
|
|
21
|
+
// startDate: 1,
|
|
22
|
+
// project: 1,
|
|
23
|
+
// typeOf: 1
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
console.log('docs found');
|
|
27
|
+
|
|
28
|
+
let i = 0;
|
|
29
|
+
let updateCount = 0;
|
|
30
|
+
await cursor.eachAsync(async (doc) => {
|
|
31
|
+
i += 1;
|
|
32
|
+
const eventSeries: Pick<
|
|
33
|
+
chevre.factory.eventSeries.IEvent,
|
|
34
|
+
'id' | 'videoFormat' | 'subEvent' | 'project' | 'startDate' | 'typeOf'
|
|
35
|
+
> = doc.toObject();
|
|
36
|
+
|
|
37
|
+
const videoFormatByOldAttribute: string[] =
|
|
38
|
+
(Array.isArray(eventSeries.videoFormat)) ? eventSeries.videoFormat.map(({ typeOf }) => typeOf) : [];
|
|
39
|
+
const videoFormatByNewAttribute: string[] =
|
|
40
|
+
(Array.isArray(eventSeries.subEvent?.videoFormat)) ? eventSeries.subEvent.videoFormat : [];
|
|
41
|
+
const alreadyMigrated = videoFormatByOldAttribute.length === videoFormatByNewAttribute.length
|
|
42
|
+
&& videoFormatByOldAttribute.every((codeValue) => videoFormatByNewAttribute.includes(codeValue))
|
|
43
|
+
&& eventSeries.subEvent?.typeOf === chevre.factory.eventType.ScreeningEvent;
|
|
44
|
+
|
|
45
|
+
if (alreadyMigrated) {
|
|
46
|
+
console.log(
|
|
47
|
+
'already migrated.', eventSeries.project.id, eventSeries.id, eventSeries.startDate, i);
|
|
48
|
+
} else {
|
|
49
|
+
const subEvent: chevre.factory.eventSeries.ISubEvent = {
|
|
50
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
51
|
+
...(videoFormatByOldAttribute.length > 0) ? { videoFormat: videoFormatByOldAttribute } : undefined
|
|
52
|
+
};
|
|
53
|
+
console.log(
|
|
54
|
+
'updating...',
|
|
55
|
+
eventSeries.project.id, eventSeries.id, eventSeries.startDate, i, videoFormatByOldAttribute, subEvent
|
|
56
|
+
);
|
|
57
|
+
await eventSeriesRepo.saveEventSeries({
|
|
58
|
+
id: eventSeries.id,
|
|
59
|
+
attributes: <any>{
|
|
60
|
+
...{
|
|
61
|
+
typeOf: eventSeries.typeOf,
|
|
62
|
+
subEvent
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
updateCount += 1;
|
|
67
|
+
console.log(
|
|
68
|
+
'updated.',
|
|
69
|
+
eventSeries.project.id, eventSeries.id, eventSeries.startDate, i);
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
console.log(i, 'docs checked');
|
|
75
|
+
console.log(updateCount, 'docs updated');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
main()
|
|
79
|
+
.then()
|
|
80
|
+
.catch(console.error);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as moment from 'moment';
|
|
3
3
|
import * as mongoose from 'mongoose';
|
|
4
4
|
|
|
5
|
-
import { chevre } from '
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
6
|
|
|
7
7
|
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
8
8
|
|
|
@@ -19,14 +19,18 @@ async function main() {
|
|
|
19
19
|
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
20
20
|
videoFormat: [],
|
|
21
21
|
soundFormat: [],
|
|
22
|
+
subEvent: {
|
|
23
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
24
|
+
videoFormat: []
|
|
25
|
+
},
|
|
22
26
|
kanaName: '',
|
|
23
27
|
startDate: moment('2023-12-08T15:00:00Z')
|
|
24
28
|
.toDate(),
|
|
25
|
-
endDate: moment('
|
|
29
|
+
endDate: moment('2027-12-08T15:00:00Z')
|
|
26
30
|
.toDate(),
|
|
27
31
|
typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
28
32
|
duration: 'PT2H',
|
|
29
|
-
name: { ja: '
|
|
33
|
+
name: { ja: '男はつらいよ 純情篇', en: 'xxx' },
|
|
30
34
|
offers: {
|
|
31
35
|
typeOf: chevre.factory.offerType.Offer
|
|
32
36
|
},
|
|
@@ -53,46 +57,47 @@ async function main() {
|
|
|
53
57
|
headline: { ja: 'xxx', en: '' }
|
|
54
58
|
},
|
|
55
59
|
$unset: {}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
$set: {
|
|
59
|
-
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
60
|
-
videoFormat: [],
|
|
61
|
-
soundFormat: [],
|
|
62
|
-
kanaName: '',
|
|
63
|
-
startDate: moment('2023-12-08T15:00:00Z')
|
|
64
|
-
.toDate(),
|
|
65
|
-
endDate: moment('2123-12-08T15:00:00Z')
|
|
66
|
-
.toDate(),
|
|
67
|
-
typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
68
|
-
duration: 'PT2H',
|
|
69
|
-
name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
|
|
70
|
-
offers: {
|
|
71
|
-
typeOf: chevre.factory.offerType.Offer
|
|
72
|
-
},
|
|
73
|
-
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
|
|
74
|
-
additionalProperty: [
|
|
75
|
-
],
|
|
76
|
-
location: {
|
|
77
|
-
branchCode: '118',
|
|
78
|
-
id: '5bfb841d5a78d7948369979a',
|
|
79
|
-
name: { ja: 'シネモーション赤坂 ', en: 'CineMotion Akasaka' },
|
|
80
|
-
typeOf: chevre.factory.placeType.MovieTheater
|
|
81
|
-
},
|
|
82
|
-
workPerformed: {
|
|
83
|
-
typeOf: chevre.factory.creativeWorkType.Movie,
|
|
84
|
-
id: '5bfb841d5a78d79483699801',
|
|
85
|
-
identifier: '071953',
|
|
86
|
-
name: {
|
|
87
|
-
ja: '男はつらいよ 純情篇'
|
|
88
|
-
},
|
|
89
|
-
duration: 'PT1H29M',
|
|
90
|
-
version: '6'
|
|
91
|
-
},
|
|
92
|
-
organizer: { id: '59d20831e53ebc2b4e774466' }
|
|
93
|
-
}
|
|
94
60
|
}
|
|
95
|
-
|
|
61
|
+
// {
|
|
62
|
+
// $set: {
|
|
63
|
+
// eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
64
|
+
// videoFormat: [],
|
|
65
|
+
// soundFormat: [],
|
|
66
|
+
// kanaName: '',
|
|
67
|
+
// startDate: moment('2023-12-08T15:00:00Z')
|
|
68
|
+
// .toDate(),
|
|
69
|
+
// endDate: moment('2123-12-08T15:00:00Z')
|
|
70
|
+
// .toDate(),
|
|
71
|
+
// typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
72
|
+
// duration: 'PT2H',
|
|
73
|
+
// name: { ja: '男はつらいよ 純情篇', en: 'xxx' },
|
|
74
|
+
// offers: {
|
|
75
|
+
// typeOf: chevre.factory.offerType.Offer
|
|
76
|
+
// },
|
|
77
|
+
// project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
|
|
78
|
+
// additionalProperty: [
|
|
79
|
+
// ],
|
|
80
|
+
// location: {
|
|
81
|
+
// branchCode: '118',
|
|
82
|
+
// id: '5bfb841d5a78d7948369979a',
|
|
83
|
+
// name: { ja: 'シネモーション赤坂 ', en: 'CineMotion Akasaka' },
|
|
84
|
+
// typeOf: chevre.factory.placeType.MovieTheater
|
|
85
|
+
// },
|
|
86
|
+
// workPerformed: {
|
|
87
|
+
// typeOf: chevre.factory.creativeWorkType.Movie,
|
|
88
|
+
// id: '5bfb841d5a78d79483699801',
|
|
89
|
+
// identifier: '071953',
|
|
90
|
+
// name: {
|
|
91
|
+
// ja: '男はつらいよ 純情篇'
|
|
92
|
+
// },
|
|
93
|
+
// duration: 'PT1H29M',
|
|
94
|
+
// version: '6'
|
|
95
|
+
// },
|
|
96
|
+
// organizer: { id: '59d20831e53ebc2b4e774466' }
|
|
97
|
+
// }
|
|
98
|
+
// }
|
|
99
|
+
],
|
|
100
|
+
{ upsert: false }
|
|
96
101
|
);
|
|
97
102
|
console.log('result:', result);
|
|
98
103
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
|
|
4
|
-
import { chevre } from '
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
5
|
|
|
6
6
|
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
7
7
|
|
|
@@ -35,8 +35,8 @@ async function main() {
|
|
|
35
35
|
},
|
|
36
36
|
$unset: {}
|
|
37
37
|
}
|
|
38
|
-
]
|
|
39
|
-
|
|
38
|
+
],
|
|
39
|
+
{ update: true }
|
|
40
40
|
);
|
|
41
41
|
console.log('result:', result);
|
|
42
42
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
|
|
4
|
-
import { chevre } from '
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
5
|
|
|
6
6
|
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
7
7
|
|
|
@@ -35,8 +35,9 @@ async function main() {
|
|
|
35
35
|
},
|
|
36
36
|
$unset: {}
|
|
37
37
|
}
|
|
38
|
-
]
|
|
39
|
-
|
|
38
|
+
],
|
|
39
|
+
{ update: true }
|
|
40
|
+
// { update: false }
|
|
40
41
|
);
|
|
41
42
|
console.log('result:', result);
|
|
42
43
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as redis from 'redis';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
const project = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const entranceGateRepo =
|
|
13
|
+
await chevre.repository.place.EntranceGate.createInstance(mongoose.connection, { id: '5bfb841d5a78d7948369979a' });
|
|
14
|
+
|
|
15
|
+
const gates = await entranceGateRepo.findEntranceGates({
|
|
16
|
+
limit: 10,
|
|
17
|
+
page: 1,
|
|
18
|
+
project: { id: { $eq: project.id } }
|
|
19
|
+
// identifier: { $in: ['GATE01', 'GATE03', 'xx'] }
|
|
20
|
+
});
|
|
21
|
+
console.log(gates);
|
|
22
|
+
console.log(gates.length);
|
|
23
|
+
|
|
24
|
+
let result = await entranceGateRepo.addEntranceGatesByIdentifierIfNotExist(
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
$set: {
|
|
28
|
+
identifier: 'sample001',
|
|
29
|
+
name: { ja: 'gateNameJa' }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
{
|
|
34
|
+
project: { id: project.id }
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
console.log(result);
|
|
38
|
+
|
|
39
|
+
result = await entranceGateRepo.updateEntranceGatesByIdentifier(
|
|
40
|
+
[
|
|
41
|
+
{
|
|
42
|
+
$set: {
|
|
43
|
+
identifier: 'sample001',
|
|
44
|
+
name: { ja: 'gateNameJaUpdated' }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
{
|
|
49
|
+
project: { id: project.id }
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
console.log(result);
|
|
53
|
+
|
|
54
|
+
result = await entranceGateRepo.deleteEntranceGatesByIdentifier(
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
identifier: 'sample001'
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
{
|
|
61
|
+
project: { id: project.id }
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
console.log(result);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
main()
|
|
68
|
+
.then(console.log)
|
|
69
|
+
.catch(console.error);
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = movieTheaterRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
// 'project.id': {
|
|
18
|
+
// $ne: 'sskts-development',
|
|
19
|
+
// $eq: 'ttts-development'
|
|
20
|
+
// }
|
|
21
|
+
// _id: { $eq: '67de46777ec0510590b68922' }
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
// _id: 1,
|
|
25
|
+
// about: 1,
|
|
26
|
+
// project: 1,
|
|
27
|
+
// typeOf: 1,
|
|
28
|
+
// issuedBy: 1
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
console.log('docs found');
|
|
32
|
+
|
|
33
|
+
let i = 0;
|
|
34
|
+
let updateCount = 0;
|
|
35
|
+
await cursor.eachAsync(async (doc) => {
|
|
36
|
+
const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
|
|
37
|
+
|
|
38
|
+
i += 1;
|
|
39
|
+
const { hasEntranceGate } = movieTheater;
|
|
40
|
+
if (!Array.isArray(hasEntranceGate)) {
|
|
41
|
+
throw new Error('hasEntranceGateLength must be an array');
|
|
42
|
+
}
|
|
43
|
+
const hasEntranceGateLength = hasEntranceGate?.length;
|
|
44
|
+
if (typeof hasEntranceGateLength !== 'number') {
|
|
45
|
+
throw new Error('hasEntranceGateLength undefined');
|
|
46
|
+
}
|
|
47
|
+
const uniqueIdentifiersByMovieTheater = hasEntranceGate.map(({ identifier }) => identifier);
|
|
48
|
+
|
|
49
|
+
const entranceGateRepo = await chevre.repository.place.EntranceGate.createInstance(mongoose.connection, { id: movieTheater.id });
|
|
50
|
+
const entranceGates = await entranceGateRepo.findEntranceGates({
|
|
51
|
+
limit: 100,
|
|
52
|
+
page: 1,
|
|
53
|
+
project: { id: { $eq: movieTheater.project.id } }
|
|
54
|
+
});
|
|
55
|
+
const entranceGateCount = entranceGates.length;
|
|
56
|
+
const uniqueIdentifiers = entranceGates.map(({ identifier }) => identifier);
|
|
57
|
+
|
|
58
|
+
const countMatched = hasEntranceGateLength === entranceGateCount;
|
|
59
|
+
const identifiersMatched = uniqueIdentifiersByMovieTheater.length === uniqueIdentifiers.length
|
|
60
|
+
&& uniqueIdentifiersByMovieTheater.every((identifier) => uniqueIdentifiers.includes(identifier));
|
|
61
|
+
console.log(uniqueIdentifiersByMovieTheater, uniqueIdentifiers);
|
|
62
|
+
|
|
63
|
+
console.log(
|
|
64
|
+
'checking...', movieTheater.project.id, movieTheater.id, hasEntranceGateLength, entranceGateCount, i);
|
|
65
|
+
if (countMatched && identifiersMatched) {
|
|
66
|
+
console.log(
|
|
67
|
+
'matched.', movieTheater.project.id, movieTheater.id, hasEntranceGateLength, entranceGateCount, i);
|
|
68
|
+
} else {
|
|
69
|
+
updateCount += 1;
|
|
70
|
+
console.log(
|
|
71
|
+
'unmatched.',
|
|
72
|
+
movieTheater.project.id, movieTheater.id, hasEntranceGateLength, entranceGateCount, i);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
console.log(i, 'docs checked');
|
|
77
|
+
console.log(updateCount, 'docs updated');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
main()
|
|
81
|
+
.then()
|
|
82
|
+
.catch(console.error);
|
|
@@ -0,0 +1,24 @@
|
|
|
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 roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const rooms = await roomRepo.findRooms({
|
|
14
|
+
limit: 20,
|
|
15
|
+
page: 1,
|
|
16
|
+
project: { id: { $eq: project.id } }
|
|
17
|
+
});
|
|
18
|
+
console.log(rooms);
|
|
19
|
+
console.log(rooms.length);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main()
|
|
23
|
+
.then(console.log)
|
|
24
|
+
.catch(console.error);
|
|
@@ -0,0 +1,28 @@
|
|
|
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 sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const sections = await sectionRepo.findSections({
|
|
14
|
+
limit: 10,
|
|
15
|
+
page: 1,
|
|
16
|
+
project: { id: { $eq: project.id } },
|
|
17
|
+
containedInPlace: {
|
|
18
|
+
branchCode: { $eq: '10' },
|
|
19
|
+
containedInPlace: { id: { $eq: '5bfb841d5a78d7948369979a' } }
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
console.log(sections);
|
|
23
|
+
console.log(sections.length);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
main()
|
|
27
|
+
.then(console.log)
|
|
28
|
+
.catch(console.error);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
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 excludedProject = { id: String(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: false });
|
|
13
|
+
|
|
14
|
+
const roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
|
|
15
|
+
const sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = roomRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
'project.id': {
|
|
20
|
+
$ne: 'sskts-development',
|
|
21
|
+
$eq: 'ttts-development'
|
|
22
|
+
}
|
|
23
|
+
// _id: { $eq: '67de46777ec0510590b68922' }
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
// _id: 1,
|
|
27
|
+
// about: 1,
|
|
28
|
+
// project: 1,
|
|
29
|
+
// typeOf: 1,
|
|
30
|
+
// issuedBy: 1
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
console.log('docs found');
|
|
34
|
+
|
|
35
|
+
const timestamp = moment()
|
|
36
|
+
.tz('Asia/Tokyo')
|
|
37
|
+
.format('YYYYMMDDHHmmss');
|
|
38
|
+
|
|
39
|
+
let i = 0;
|
|
40
|
+
let updateCount = 0;
|
|
41
|
+
await cursor.eachAsync(async (doc) => {
|
|
42
|
+
const room: chevre.factory.place.screeningRoom.IPlace = doc.toObject();
|
|
43
|
+
|
|
44
|
+
const sections = room.containsPlace;
|
|
45
|
+
if (Array.isArray(sections)) {
|
|
46
|
+
for (const section of sections) {
|
|
47
|
+
i += 1;
|
|
48
|
+
const movieTheaterCode = room.containedInPlace?.branchCode;
|
|
49
|
+
if (typeof movieTheaterCode !== 'string') {
|
|
50
|
+
throw new Error('movieTheaterCode undefined');
|
|
51
|
+
}
|
|
52
|
+
const alreadyMigrated = typeof (<any>section).identifier === 'string';
|
|
53
|
+
|
|
54
|
+
if (alreadyMigrated) {
|
|
55
|
+
console.log(
|
|
56
|
+
'already migrated.', room.project.id, movieTheaterCode, room.branchCode, section.branchCode, i);
|
|
57
|
+
} else {
|
|
58
|
+
// if (typeof identity.id !== 'string') {
|
|
59
|
+
// throw new Error(`id undefined ${identity.id}`);
|
|
60
|
+
// }
|
|
61
|
+
const identifier = `${movieTheaterCode}:${room.branchCode}:${section.branchCode}:${timestamp}`;
|
|
62
|
+
|
|
63
|
+
console.log(
|
|
64
|
+
'updating...',
|
|
65
|
+
identifier,
|
|
66
|
+
room.project.id, movieTheaterCode, room.branchCode, section.branchCode, i);
|
|
67
|
+
await sectionRepo.migrateSectionIdentifier({
|
|
68
|
+
project: { id: room.project.id },
|
|
69
|
+
identifier,
|
|
70
|
+
branchCode: section.branchCode,
|
|
71
|
+
containedInPlace: {
|
|
72
|
+
branchCode: room.branchCode,
|
|
73
|
+
containedInPlace: {
|
|
74
|
+
branchCode: movieTheaterCode
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
updateCount += 1;
|
|
79
|
+
console.log(
|
|
80
|
+
'updated.', room.project.id, movieTheaterCode, room.branchCode, section.branchCode, i);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
console.log(i, 'docs checked');
|
|
87
|
+
console.log(updateCount, 'docs updated');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
main()
|
|
91
|
+
.then()
|
|
92
|
+
.catch(console.error);
|