@chevre/domain 21.4.0-alpha.5 → 21.4.0-alpha.7
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/cleanActions.ts +1 -1
- package/example/src/chevre/migrateEventOrganizer.ts +105 -0
- package/lib/chevre/repo/event.js +31 -25
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +7 -7
- package/lib/chevre/repo/mongoose/schemas/event.js +15 -3
- package/package.json +1 -1
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +0 -90
|
@@ -5,7 +5,7 @@ import * as mongoose from 'mongoose';
|
|
|
5
5
|
import { chevre } from '../../../lib/index';
|
|
6
6
|
|
|
7
7
|
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
9
|
|
|
10
10
|
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
11
11
|
|
|
@@ -0,0 +1,105 @@
|
|
|
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 eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = eventRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
// 'project.id': { $eq: project.id },
|
|
20
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
|
+
typeOf: {
|
|
22
|
+
$in: [
|
|
23
|
+
chevre.factory.eventType.ScreeningEvent,
|
|
24
|
+
chevre.factory.eventType.ScreeningEventSeries
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
// startDate: {
|
|
28
|
+
// $gte: moment()
|
|
29
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
30
|
+
// .add(-6, 'months')
|
|
31
|
+
// .toDate()
|
|
32
|
+
// }
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
_id: 1,
|
|
36
|
+
project: 1,
|
|
37
|
+
location: 1,
|
|
38
|
+
superEvent: 1,
|
|
39
|
+
startDate: 1,
|
|
40
|
+
typeOf: 1,
|
|
41
|
+
organizer: 1
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
console.log('events found');
|
|
45
|
+
|
|
46
|
+
let i = 0;
|
|
47
|
+
let updateCount = 0;
|
|
48
|
+
await cursor.eachAsync(async (doc) => {
|
|
49
|
+
i += 1;
|
|
50
|
+
const event: chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent
|
|
51
|
+
| chevre.factory.eventType.ScreeningEventSeries> = doc.toObject();
|
|
52
|
+
|
|
53
|
+
const organizerId = event.organizer?.id;
|
|
54
|
+
|
|
55
|
+
const alreadyMigrated = typeof organizerId === 'string';
|
|
56
|
+
|
|
57
|
+
if (alreadyMigrated) {
|
|
58
|
+
console.log('already exist...', event.project.id, event.id, event.startDate, organizerId, i);
|
|
59
|
+
} else {
|
|
60
|
+
let movieTheaterId: string;
|
|
61
|
+
if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
|
|
62
|
+
movieTheaterId = event.location.id;
|
|
63
|
+
} else {
|
|
64
|
+
movieTheaterId = event.superEvent.location.id;
|
|
65
|
+
}
|
|
66
|
+
const movieTheaters = <Pick<chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom, 'parentOrganization'>[]>
|
|
67
|
+
await placeRepo.searchMovieTheaters(
|
|
68
|
+
{
|
|
69
|
+
limit: 1,
|
|
70
|
+
page: 1,
|
|
71
|
+
project: { id: { $eq: event.project.id } },
|
|
72
|
+
id: { $eq: movieTheaterId }
|
|
73
|
+
},
|
|
74
|
+
['parentOrganization'],
|
|
75
|
+
[]
|
|
76
|
+
);
|
|
77
|
+
const movieTheater = movieTheaters.shift();
|
|
78
|
+
const sellerId = movieTheater?.parentOrganization?.id;
|
|
79
|
+
console.log('movieTheater found', event.project.id, event.id, event.startDate, 'sellerId:', sellerId, i);
|
|
80
|
+
if (typeof sellerId !== 'string') {
|
|
81
|
+
throw new Error('movieTheater not found');
|
|
82
|
+
}
|
|
83
|
+
const newOrganizer: chevre.factory.event.screeningEventSeries.IOrganizer = {
|
|
84
|
+
id: sellerId
|
|
85
|
+
};
|
|
86
|
+
console.log('updating event...', event.project.id, event.id, event.startDate, i);
|
|
87
|
+
await eventRepo.updatePartiallyById({
|
|
88
|
+
id: event.id,
|
|
89
|
+
attributes: <any>{
|
|
90
|
+
typeOf: event.typeOf,
|
|
91
|
+
organizer: newOrganizer
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
updateCount += 1;
|
|
95
|
+
console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
console.log(i, 'events checked');
|
|
100
|
+
console.log(updateCount, 'events updated');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
main()
|
|
104
|
+
.then()
|
|
105
|
+
.catch(console.error);
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -51,7 +51,7 @@ class MongoRepository {
|
|
|
51
51
|
}
|
|
52
52
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
53
53
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
54
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39;
|
|
54
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41;
|
|
55
55
|
const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
|
|
56
56
|
const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
57
57
|
if (typeof projectIdEq === 'string') {
|
|
@@ -59,7 +59,13 @@ class MongoRepository {
|
|
|
59
59
|
'project.id': { $eq: projectIdEq }
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
const
|
|
62
|
+
const organizerIdEq = (_d = (_c = conditions.organizer) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
63
|
+
if (typeof organizerIdEq === 'string') {
|
|
64
|
+
andConditions.push({
|
|
65
|
+
'organizer.id': { $exists: true, $eq: organizerIdEq }
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const idIn = (_e = conditions.id) === null || _e === void 0 ? void 0 : _e.$in;
|
|
63
69
|
if (Array.isArray(idIn)) {
|
|
64
70
|
andConditions.push({
|
|
65
71
|
_id: { $in: idIn }
|
|
@@ -114,17 +120,17 @@ class MongoRepository {
|
|
|
114
120
|
endDate: { $lte: conditions.endThrough }
|
|
115
121
|
});
|
|
116
122
|
}
|
|
117
|
-
const locationBranchCodeEq = (
|
|
123
|
+
const locationBranchCodeEq = (_g = (_f = conditions.location) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
118
124
|
if (typeof locationBranchCodeEq === 'string') {
|
|
119
125
|
andConditions.push({ 'location.branchCode': { $exists: true, $eq: locationBranchCodeEq } });
|
|
120
126
|
}
|
|
121
|
-
const locationBranchCodeIn = (
|
|
127
|
+
const locationBranchCodeIn = (_j = (_h = conditions.location) === null || _h === void 0 ? void 0 : _h.branchCode) === null || _j === void 0 ? void 0 : _j.$in;
|
|
122
128
|
if (Array.isArray(locationBranchCodeIn)) {
|
|
123
129
|
andConditions.push({ 'location.branchCode': { $exists: true, $in: locationBranchCodeIn } });
|
|
124
130
|
}
|
|
125
131
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
126
132
|
/* istanbul ignore else */
|
|
127
|
-
const hasOfferCatalogIdEq = (
|
|
133
|
+
const hasOfferCatalogIdEq = (_l = (_k = conditions.hasOfferCatalog) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
128
134
|
if (typeof hasOfferCatalogIdEq === 'string') {
|
|
129
135
|
andConditions.push({
|
|
130
136
|
'hasOfferCatalog.id': {
|
|
@@ -133,7 +139,7 @@ class MongoRepository {
|
|
|
133
139
|
}
|
|
134
140
|
});
|
|
135
141
|
}
|
|
136
|
-
const additionalPropertyElemMatch = (
|
|
142
|
+
const additionalPropertyElemMatch = (_m = conditions.additionalProperty) === null || _m === void 0 ? void 0 : _m.$elemMatch;
|
|
137
143
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
138
144
|
andConditions.push({
|
|
139
145
|
additionalProperty: {
|
|
@@ -149,7 +155,7 @@ class MongoRepository {
|
|
|
149
155
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
150
156
|
/* istanbul ignore else */
|
|
151
157
|
if (params.offers !== undefined) {
|
|
152
|
-
const itemOfferedIdIn4event = (
|
|
158
|
+
const itemOfferedIdIn4event = (_p = (_o = params.offers.itemOffered) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$in;
|
|
153
159
|
if (Array.isArray(itemOfferedIdIn4event)) {
|
|
154
160
|
andConditions.push({
|
|
155
161
|
'offers.itemOffered.id': {
|
|
@@ -199,8 +205,8 @@ class MongoRepository {
|
|
|
199
205
|
}
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
|
-
const sellerMakesOfferElemMatch4event = (
|
|
203
|
-
if (typeof ((
|
|
208
|
+
const sellerMakesOfferElemMatch4event = (_s = (_r = (_q = params.offers) === null || _q === void 0 ? void 0 : _q.seller) === null || _r === void 0 ? void 0 : _r.makesOffer) === null || _s === void 0 ? void 0 : _s.$elemMatch;
|
|
209
|
+
if (typeof ((_t = sellerMakesOfferElemMatch4event === null || sellerMakesOfferElemMatch4event === void 0 ? void 0 : sellerMakesOfferElemMatch4event['availableAtOrFrom.id']) === null || _t === void 0 ? void 0 : _t.$eq) === 'string') {
|
|
204
210
|
andConditions.push({
|
|
205
211
|
'offers.seller.makesOffer': {
|
|
206
212
|
$exists: true,
|
|
@@ -208,7 +214,7 @@ class MongoRepository {
|
|
|
208
214
|
}
|
|
209
215
|
});
|
|
210
216
|
}
|
|
211
|
-
const reservationForIdentifierEq = (
|
|
217
|
+
const reservationForIdentifierEq = (_y = (_x = (_w = (_v = (_u = params.offers) === null || _u === void 0 ? void 0 : _u.itemOffered) === null || _v === void 0 ? void 0 : _v.serviceOutput) === null || _w === void 0 ? void 0 : _w.reservationFor) === null || _x === void 0 ? void 0 : _x.identifier) === null || _y === void 0 ? void 0 : _y.$eq;
|
|
212
218
|
if (typeof reservationForIdentifierEq === 'string') {
|
|
213
219
|
andConditions.push({
|
|
214
220
|
'offers.itemOffered.serviceOutput.reservationFor.identifier': {
|
|
@@ -217,7 +223,7 @@ class MongoRepository {
|
|
|
217
223
|
}
|
|
218
224
|
});
|
|
219
225
|
}
|
|
220
|
-
const reservationForArrivalBusStopBranchCodeEq = (
|
|
226
|
+
const reservationForArrivalBusStopBranchCodeEq = (_4 = (_3 = (_2 = (_1 = (_0 = (_z = params.offers) === null || _z === void 0 ? void 0 : _z.itemOffered) === null || _0 === void 0 ? void 0 : _0.serviceOutput) === null || _1 === void 0 ? void 0 : _1.reservationFor) === null || _2 === void 0 ? void 0 : _2.arrivalBusStop) === null || _3 === void 0 ? void 0 : _3.branchCode) === null || _4 === void 0 ? void 0 : _4.$eq;
|
|
221
227
|
if (typeof reservationForArrivalBusStopBranchCodeEq === 'string') {
|
|
222
228
|
andConditions.push({
|
|
223
229
|
'offers.itemOffered.serviceOutput.reservationFor.arrivalBusStop.branchCode': {
|
|
@@ -226,7 +232,7 @@ class MongoRepository {
|
|
|
226
232
|
}
|
|
227
233
|
});
|
|
228
234
|
}
|
|
229
|
-
const reservationForDepartureBusStopBranchCodeEq = (
|
|
235
|
+
const reservationForDepartureBusStopBranchCodeEq = (_10 = (_9 = (_8 = (_7 = (_6 = (_5 = params.offers) === null || _5 === void 0 ? void 0 : _5.itemOffered) === null || _6 === void 0 ? void 0 : _6.serviceOutput) === null || _7 === void 0 ? void 0 : _7.reservationFor) === null || _8 === void 0 ? void 0 : _8.departureBusStop) === null || _9 === void 0 ? void 0 : _9.branchCode) === null || _10 === void 0 ? void 0 : _10.$eq;
|
|
230
236
|
if (typeof reservationForDepartureBusStopBranchCodeEq === 'string') {
|
|
231
237
|
andConditions.push({
|
|
232
238
|
'offers.itemOffered.serviceOutput.reservationFor.departureBusStop.branchCode': {
|
|
@@ -260,7 +266,7 @@ class MongoRepository {
|
|
|
260
266
|
}
|
|
261
267
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
262
268
|
/* istanbul ignore else */
|
|
263
|
-
const superEventLocationIdEq = (
|
|
269
|
+
const superEventLocationIdEq = (_13 = (_12 = (_11 = params.superEvent) === null || _11 === void 0 ? void 0 : _11.location) === null || _12 === void 0 ? void 0 : _12.id) === null || _13 === void 0 ? void 0 : _13.$eq;
|
|
264
270
|
if (typeof superEventLocationIdEq === 'string') {
|
|
265
271
|
andConditions.push({
|
|
266
272
|
'superEvent.location.id': {
|
|
@@ -303,7 +309,7 @@ class MongoRepository {
|
|
|
303
309
|
});
|
|
304
310
|
}
|
|
305
311
|
}
|
|
306
|
-
const itemOfferedIdIn = (
|
|
312
|
+
const itemOfferedIdIn = (_16 = (_15 = (_14 = params.offers) === null || _14 === void 0 ? void 0 : _14.itemOffered) === null || _15 === void 0 ? void 0 : _15.id) === null || _16 === void 0 ? void 0 : _16.$in;
|
|
307
313
|
if (Array.isArray(itemOfferedIdIn)) {
|
|
308
314
|
andConditions.push({
|
|
309
315
|
'offers.itemOffered.id': {
|
|
@@ -312,7 +318,7 @@ class MongoRepository {
|
|
|
312
318
|
}
|
|
313
319
|
});
|
|
314
320
|
}
|
|
315
|
-
const itemOfferedTicketedSeatTypeOfIn = (
|
|
321
|
+
const itemOfferedTicketedSeatTypeOfIn = (_21 = (_20 = (_19 = (_18 = (_17 = params.offers) === null || _17 === void 0 ? void 0 : _17.itemOffered) === null || _18 === void 0 ? void 0 : _18.serviceOutput) === null || _19 === void 0 ? void 0 : _19.reservedTicket) === null || _20 === void 0 ? void 0 : _20.ticketedSeat) === null || _21 === void 0 ? void 0 : _21.typeOfs;
|
|
316
322
|
if (Array.isArray(itemOfferedTicketedSeatTypeOfIn)) {
|
|
317
323
|
andConditions.push({
|
|
318
324
|
'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
|
|
@@ -321,7 +327,7 @@ class MongoRepository {
|
|
|
321
327
|
}
|
|
322
328
|
});
|
|
323
329
|
}
|
|
324
|
-
const itemOfferedServiceTypeIdIn = (
|
|
330
|
+
const itemOfferedServiceTypeIdIn = (_24 = (_23 = (_22 = params.offers) === null || _22 === void 0 ? void 0 : _22.itemOffered) === null || _23 === void 0 ? void 0 : _23.serviceType) === null || _24 === void 0 ? void 0 : _24.ids;
|
|
325
331
|
if (Array.isArray(itemOfferedServiceTypeIdIn)) {
|
|
326
332
|
andConditions.push({
|
|
327
333
|
'offers.itemOffered.serviceType.id': {
|
|
@@ -330,8 +336,8 @@ class MongoRepository {
|
|
|
330
336
|
}
|
|
331
337
|
});
|
|
332
338
|
}
|
|
333
|
-
const sellerMakesOfferElemMatch = (
|
|
334
|
-
if (typeof ((
|
|
339
|
+
const sellerMakesOfferElemMatch = (_27 = (_26 = (_25 = params.offers) === null || _25 === void 0 ? void 0 : _25.seller) === null || _26 === void 0 ? void 0 : _26.makesOffer) === null || _27 === void 0 ? void 0 : _27.$elemMatch;
|
|
340
|
+
if (typeof ((_28 = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _28 === void 0 ? void 0 : _28.$eq) === 'string') {
|
|
335
341
|
andConditions.push({
|
|
336
342
|
'offers.seller.makesOffer': {
|
|
337
343
|
$exists: true,
|
|
@@ -368,7 +374,7 @@ class MongoRepository {
|
|
|
368
374
|
]
|
|
369
375
|
});
|
|
370
376
|
}
|
|
371
|
-
const locationIdEq = (
|
|
377
|
+
const locationIdEq = (_30 = (_29 = params.location) === null || _29 === void 0 ? void 0 : _29.id) === null || _30 === void 0 ? void 0 : _30.$eq;
|
|
372
378
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
373
379
|
/* istanbul ignore else */
|
|
374
380
|
if (typeof locationIdEq === 'string') {
|
|
@@ -390,7 +396,7 @@ class MongoRepository {
|
|
|
390
396
|
});
|
|
391
397
|
}
|
|
392
398
|
}
|
|
393
|
-
const workPerformedIdentifierIn = (
|
|
399
|
+
const workPerformedIdentifierIn = (_31 = params.workPerformed) === null || _31 === void 0 ? void 0 : _31.identifiers;
|
|
394
400
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
395
401
|
/* istanbul ignore else */
|
|
396
402
|
if (Array.isArray(workPerformedIdentifierIn)) {
|
|
@@ -398,13 +404,13 @@ class MongoRepository {
|
|
|
398
404
|
'workPerformed.identifier': { $exists: true, $in: workPerformedIdentifierIn }
|
|
399
405
|
});
|
|
400
406
|
}
|
|
401
|
-
const workPerformedVersionEq = (
|
|
407
|
+
const workPerformedVersionEq = (_33 = (_32 = params.workPerformed) === null || _32 === void 0 ? void 0 : _32.version) === null || _33 === void 0 ? void 0 : _33.$eq;
|
|
402
408
|
if (typeof workPerformedVersionEq === 'string') {
|
|
403
409
|
andConditions.push({
|
|
404
410
|
'workPerformed.version': { $exists: true, $eq: workPerformedVersionEq }
|
|
405
411
|
});
|
|
406
412
|
}
|
|
407
|
-
const videoFormatTypeOfEq = (
|
|
413
|
+
const videoFormatTypeOfEq = (_35 = (_34 = params.videoFormat) === null || _34 === void 0 ? void 0 : _34.typeOf) === null || _35 === void 0 ? void 0 : _35.$eq;
|
|
408
414
|
if (typeof videoFormatTypeOfEq === 'string') {
|
|
409
415
|
andConditions.push({
|
|
410
416
|
'videoFormat.typeOf': {
|
|
@@ -413,7 +419,7 @@ class MongoRepository {
|
|
|
413
419
|
}
|
|
414
420
|
});
|
|
415
421
|
}
|
|
416
|
-
const videoFormatTypeOfIn = (
|
|
422
|
+
const videoFormatTypeOfIn = (_37 = (_36 = params.videoFormat) === null || _36 === void 0 ? void 0 : _36.typeOf) === null || _37 === void 0 ? void 0 : _37.$in;
|
|
417
423
|
if (Array.isArray(videoFormatTypeOfIn)) {
|
|
418
424
|
andConditions.push({
|
|
419
425
|
'videoFormat.typeOf': {
|
|
@@ -422,7 +428,7 @@ class MongoRepository {
|
|
|
422
428
|
}
|
|
423
429
|
});
|
|
424
430
|
}
|
|
425
|
-
const soundFormatTypeOfEq = (
|
|
431
|
+
const soundFormatTypeOfEq = (_39 = (_38 = params.soundFormat) === null || _38 === void 0 ? void 0 : _38.typeOf) === null || _39 === void 0 ? void 0 : _39.$eq;
|
|
426
432
|
if (typeof soundFormatTypeOfEq === 'string') {
|
|
427
433
|
andConditions.push({
|
|
428
434
|
'soundFormat.typeOf': {
|
|
@@ -431,7 +437,7 @@ class MongoRepository {
|
|
|
431
437
|
}
|
|
432
438
|
});
|
|
433
439
|
}
|
|
434
|
-
const soundFormatTypeOfIn = (
|
|
440
|
+
const soundFormatTypeOfIn = (_41 = (_40 = params.soundFormat) === null || _40 === void 0 ? void 0 : _40.typeOf) === null || _41 === void 0 ? void 0 : _41.$in;
|
|
435
441
|
if (Array.isArray(soundFormatTypeOfIn)) {
|
|
436
442
|
andConditions.push({
|
|
437
443
|
'soundFormat.typeOf': {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { Schema } from 'mongoose';
|
|
26
26
|
declare const modelName = "Event";
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* イベントスキーマ
|
|
29
29
|
*/
|
|
30
30
|
declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
31
31
|
collection: string;
|
|
@@ -53,11 +53,12 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
53
53
|
};
|
|
54
54
|
}, {
|
|
55
55
|
typeOf: string;
|
|
56
|
+
project: any;
|
|
56
57
|
checkInCount: number;
|
|
57
58
|
attendeeCount: number;
|
|
59
|
+
organizer: any;
|
|
58
60
|
_id?: string | undefined;
|
|
59
61
|
name?: any;
|
|
60
|
-
project?: any;
|
|
61
62
|
alternateName?: any;
|
|
62
63
|
description?: any;
|
|
63
64
|
additionalProperty?: any;
|
|
@@ -77,7 +78,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
77
78
|
aggregateEntranceGate?: any;
|
|
78
79
|
aggregateReservation?: any;
|
|
79
80
|
aggregateOffer?: any;
|
|
80
|
-
organizer?: any;
|
|
81
81
|
maximumAttendeeCapacity?: number | undefined;
|
|
82
82
|
remainingAttendeeCapacity?: number | undefined;
|
|
83
83
|
videoFormat?: any;
|
|
@@ -87,11 +87,12 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
87
87
|
kanaName?: string | undefined;
|
|
88
88
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
89
89
|
typeOf: string;
|
|
90
|
+
project: any;
|
|
90
91
|
checkInCount: number;
|
|
91
92
|
attendeeCount: number;
|
|
93
|
+
organizer: any;
|
|
92
94
|
_id?: string | undefined;
|
|
93
95
|
name?: any;
|
|
94
|
-
project?: any;
|
|
95
96
|
alternateName?: any;
|
|
96
97
|
description?: any;
|
|
97
98
|
additionalProperty?: any;
|
|
@@ -111,7 +112,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
111
112
|
aggregateEntranceGate?: any;
|
|
112
113
|
aggregateReservation?: any;
|
|
113
114
|
aggregateOffer?: any;
|
|
114
|
-
organizer?: any;
|
|
115
115
|
maximumAttendeeCapacity?: number | undefined;
|
|
116
116
|
remainingAttendeeCapacity?: number | undefined;
|
|
117
117
|
videoFormat?: any;
|
|
@@ -121,11 +121,12 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
121
121
|
kanaName?: string | undefined;
|
|
122
122
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
123
123
|
typeOf: string;
|
|
124
|
+
project: any;
|
|
124
125
|
checkInCount: number;
|
|
125
126
|
attendeeCount: number;
|
|
127
|
+
organizer: any;
|
|
126
128
|
_id?: string | undefined;
|
|
127
129
|
name?: any;
|
|
128
|
-
project?: any;
|
|
129
130
|
alternateName?: any;
|
|
130
131
|
description?: any;
|
|
131
132
|
additionalProperty?: any;
|
|
@@ -145,7 +146,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
145
146
|
aggregateEntranceGate?: any;
|
|
146
147
|
aggregateReservation?: any;
|
|
147
148
|
aggregateOffer?: any;
|
|
148
|
-
organizer?: any;
|
|
149
149
|
maximumAttendeeCapacity?: number | undefined;
|
|
150
150
|
remainingAttendeeCapacity?: number | undefined;
|
|
151
151
|
videoFormat?: any;
|
|
@@ -7,10 +7,17 @@ const factory = require("../../../factory");
|
|
|
7
7
|
const modelName = 'Event';
|
|
8
8
|
exports.modelName = modelName;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* イベントスキーマ
|
|
11
11
|
*/
|
|
12
12
|
const schema = new mongoose_1.Schema({
|
|
13
|
-
project:
|
|
13
|
+
project: {
|
|
14
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
organizer: {
|
|
18
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
14
21
|
_id: String,
|
|
15
22
|
typeOf: {
|
|
16
23
|
type: String,
|
|
@@ -46,7 +53,6 @@ const schema = new mongoose_1.Schema({
|
|
|
46
53
|
aggregateEntranceGate: mongoose_1.SchemaTypes.Mixed,
|
|
47
54
|
aggregateReservation: mongoose_1.SchemaTypes.Mixed,
|
|
48
55
|
aggregateOffer: mongoose_1.SchemaTypes.Mixed,
|
|
49
|
-
organizer: mongoose_1.SchemaTypes.Mixed,
|
|
50
56
|
coaInfo: mongoose_1.SchemaTypes.Mixed
|
|
51
57
|
}, {
|
|
52
58
|
collection: 'events',
|
|
@@ -79,6 +85,12 @@ schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
|
|
|
79
85
|
schema.index({ 'project.id': 1, startDate: 1 }, {
|
|
80
86
|
name: 'searchByProjectId-v20220721'
|
|
81
87
|
});
|
|
88
|
+
schema.index({ 'organizer.id': 1, startDate: 1 }, {
|
|
89
|
+
name: 'searchByOrganizerId',
|
|
90
|
+
partialFilterExpression: {
|
|
91
|
+
'organizer.id': { $exists: true }
|
|
92
|
+
}
|
|
93
|
+
});
|
|
82
94
|
schema.index({ typeOf: 1, startDate: 1 }, { name: 'searchByTypeOf' });
|
|
83
95
|
schema.index({ eventStatus: 1, startDate: 1 }, { name: 'searchByEventStatus' });
|
|
84
96
|
schema.index({ name: 1, startDate: 1 }, { name: 'searchByName' });
|
package/package.json
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
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
|
-
|
|
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);
|
|
14
|
-
|
|
15
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const cursor = eventRepo.getCursor(
|
|
18
|
-
{
|
|
19
|
-
// 'project.id': { $eq: project.id },
|
|
20
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
22
|
-
startDate: {
|
|
23
|
-
$gte: moment()
|
|
24
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
25
|
-
.add(-6, 'months')
|
|
26
|
-
.toDate()
|
|
27
|
-
}
|
|
28
|
-
// _id: { $eq: 'al6aff83w' }
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
// _id: 1,
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
console.log('events found');
|
|
35
|
-
|
|
36
|
-
let i = 0;
|
|
37
|
-
let updateCount = 0;
|
|
38
|
-
await cursor.eachAsync(async (doc) => {
|
|
39
|
-
i += 1;
|
|
40
|
-
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
41
|
-
|
|
42
|
-
const eventOffers = <chevre.factory.event.screeningEvent.IOffer | undefined>event.offers;
|
|
43
|
-
if (eventOffers === undefined) {
|
|
44
|
-
throw new Error('event.offers undefined');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const availableChannel = eventOffers.itemOffered.availableChannel;
|
|
48
|
-
|
|
49
|
-
const alreadyMigrated = availableChannel?.typeOf === 'ServiceChannel';
|
|
50
|
-
|
|
51
|
-
if (alreadyMigrated) {
|
|
52
|
-
console.log(
|
|
53
|
-
'already exist...', event.project.id, event.id, event.startDate, availableChannel.serviceLocation.branchCode, i);
|
|
54
|
-
} else {
|
|
55
|
-
const newAvailableChannel: chevre.factory.reservation.IServiceChannel = {
|
|
56
|
-
typeOf: 'ServiceChannel',
|
|
57
|
-
serviceLocation: {
|
|
58
|
-
typeOf: event.location.typeOf,
|
|
59
|
-
branchCode: event.location.branchCode,
|
|
60
|
-
name: event.location.name,
|
|
61
|
-
containedInPlace: {
|
|
62
|
-
typeOf: event.superEvent.location.typeOf,
|
|
63
|
-
id: event.superEvent.location.id,
|
|
64
|
-
branchCode: event.superEvent.location.branchCode,
|
|
65
|
-
name: event.superEvent.location.name
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
console.log(
|
|
70
|
-
'updating seller...', event.project.id, event.id, event.startDate, newAvailableChannel.serviceLocation.branchCode, i);
|
|
71
|
-
await eventRepo.updatePartiallyById({
|
|
72
|
-
id: event.id,
|
|
73
|
-
attributes: <any>{
|
|
74
|
-
typeOf: event.typeOf,
|
|
75
|
-
'offers.itemOffered.availableChannel': newAvailableChannel
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
updateCount += 1;
|
|
79
|
-
console.log(
|
|
80
|
-
'updated...', event.project.id, event.id, event.startDate, i);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
console.log(i, 'events checked');
|
|
85
|
-
console.log(updateCount, 'events updated');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
main()
|
|
89
|
-
.then()
|
|
90
|
-
.catch(console.error);
|