@chevre/domain 23.2.0-alpha.13 → 23.2.0-alpha.14

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.
@@ -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': { $ne: 'sskts-development' }
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);
@@ -11,7 +11,7 @@ mongoose.Model.on('index', (...args) => {
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- await chevre.repository.EventOffer.createInstance(mongoose.connection);
14
+ await chevre.repository.EventSeries.createInstance(mongoose.connection);
15
15
  console.log('success!');
16
16
  }
17
17
 
@@ -184,21 +184,25 @@ class EventSeriesRepo {
184
184
  }
185
185
  const videoFormatTypeOfEq = (_t = (_s = conditions.videoFormat) === null || _s === void 0 ? void 0 : _s.typeOf) === null || _t === void 0 ? void 0 : _t.$eq;
186
186
  if (typeof videoFormatTypeOfEq === 'string') {
187
- andConditions.push({
188
- 'videoFormat.typeOf': {
189
- $exists: true,
190
- $eq: videoFormatTypeOfEq
191
- }
192
- });
187
+ // 新しい参照先へ変更(2025-12-31~)
188
+ // andConditions.push({
189
+ // 'videoFormat.typeOf': {
190
+ // $exists: true,
191
+ // $eq: videoFormatTypeOfEq
192
+ // }
193
+ // });
194
+ andConditions.push({ 'subEvent.videoFormat': { $exists: true, $eq: videoFormatTypeOfEq } });
193
195
  }
194
196
  const videoFormatTypeOfIn = (_v = (_u = conditions.videoFormat) === null || _u === void 0 ? void 0 : _u.typeOf) === null || _v === void 0 ? void 0 : _v.$in;
195
197
  if (Array.isArray(videoFormatTypeOfIn)) {
196
- andConditions.push({
197
- 'videoFormat.typeOf': {
198
- $exists: true,
199
- $in: videoFormatTypeOfIn
200
- }
201
- });
198
+ // 新しい参照先へ変更(2025-12-31~)
199
+ // andConditions.push({
200
+ // 'videoFormat.typeOf': {
201
+ // $exists: true,
202
+ // $in: videoFormatTypeOfIn
203
+ // }
204
+ // });
205
+ andConditions.push({ 'subEvent.videoFormat': { $exists: true, $in: videoFormatTypeOfIn } });
202
206
  }
203
207
  const soundFormatTypeOfEq = (_x = (_w = conditions.soundFormat) === null || _w === void 0 ? void 0 : _w.typeOf) === null || _x === void 0 ? void 0 : _x.$eq;
204
208
  if (typeof soundFormatTypeOfEq === 'string') {
@@ -147,6 +147,15 @@ const indexes = [
147
147
  }
148
148
  }
149
149
  ],
150
+ [
151
+ { 'subEvent.videoFormat': 1, startDate: 1 },
152
+ {
153
+ name: 'subEventVideoFormat',
154
+ partialFilterExpression: {
155
+ 'subEvent.videoFormat': { $exists: true }
156
+ }
157
+ }
158
+ ],
150
159
  [
151
160
  { 'soundFormat.typeOf': 1, startDate: 1 },
152
161
  {
@@ -127,7 +127,7 @@ function searchTicketOffersByItemOffered(params) {
127
127
  function searchEventTicketOffersByEvent(params) {
128
128
  // tslint:disable-next-line:max-func-body-length
129
129
  return (repos) => __awaiter(this, void 0, void 0, function* () {
130
- var _a;
130
+ var _a, _b;
131
131
  const event = params.event;
132
132
  let soundFormatTypes = [];
133
133
  let videoFormatTypes = [];
@@ -137,13 +137,16 @@ function searchEventTicketOffersByEvent(params) {
137
137
  page: 1,
138
138
  id: { $eq: event.superEvent.id }
139
139
  // typeOf: factory.eventType.ScreeningEventSeries
140
- }, ['soundFormat', 'videoFormat', 'subEvent']);
140
+ },
141
+ // ['soundFormat', 'videoFormat', 'subEvent']
142
+ ['soundFormat', 'subEvent']);
141
143
  const superEvent = superEvents.shift();
142
144
  if (superEvent === undefined) {
143
145
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
144
146
  }
145
147
  soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
146
- videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
148
+ // videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
149
+ videoFormatTypes = (Array.isArray((_a = superEvent.subEvent) === null || _a === void 0 ? void 0 : _a.videoFormat)) ? superEvent.subEvent.videoFormat : [];
147
150
  }
148
151
  const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
149
152
  // 上映方式がなければMovieTicket除外(2023-02-21~)
@@ -151,7 +154,7 @@ function searchEventTicketOffersByEvent(params) {
151
154
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
152
155
  const eventOffers = event.offers;
153
156
  const { availableOffers, sortedOfferIds } = yield searchTicketOffersByItemOffered({
154
- itemOffered: { id: String((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) },
157
+ itemOffered: { id: String((_b = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _b === void 0 ? void 0 : _b.id) },
155
158
  // ids: params.ids,
156
159
  store: params.store,
157
160
  limit: params.limit,
@@ -28,7 +28,7 @@ function getUnacceptedPaymentMethodByEvent(params) {
28
28
  */
29
29
  function searchOfferAppliesToMovieTicket(params) {
30
30
  return (repos) => __awaiter(this, void 0, void 0, function* () {
31
- var _a, _b, _c, _d;
31
+ var _a, _b, _c, _d, _e;
32
32
  // optimize(2024-07-18~)
33
33
  const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, ['project', 'startDate', 'typeOf', 'superEvent.id', 'offers.itemOffered.id', 'offers.unacceptedPaymentMethod']);
34
34
  // let soundFormatTypes: string[] = [];
@@ -39,13 +39,16 @@ function searchOfferAppliesToMovieTicket(params) {
39
39
  page: 1,
40
40
  id: { $eq: event.superEvent.id }
41
41
  // typeOf: factory.eventType.ScreeningEventSeries
42
- }, ['soundFormat', 'videoFormat', 'subEvent']);
42
+ },
43
+ // ['soundFormat', 'videoFormat', 'subEvent']
44
+ ['soundFormat', 'subEvent']);
43
45
  const superEvent = superEvents.shift();
44
46
  if (superEvent === undefined) {
45
47
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
46
48
  }
47
49
  // soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
48
- videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
50
+ // videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
51
+ videoFormatTypes = (Array.isArray((_a = superEvent.subEvent) === null || _a === void 0 ? void 0 : _a.videoFormat)) ? superEvent.subEvent.videoFormat : [];
49
52
  }
50
53
  const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
51
54
  // 上映方式がなければMovieTicket除外
@@ -53,7 +56,7 @@ function searchOfferAppliesToMovieTicket(params) {
53
56
  // 興行設定があれば興行のカタログを参照する
54
57
  const eventOffers = event.offers;
55
58
  let catalogId;
56
- if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
59
+ if (typeof ((_b = eventOffers.itemOffered) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
57
60
  const eventService = (yield repos.product.projectFields({
58
61
  limit: 1,
59
62
  page: 1,
@@ -65,7 +68,7 @@ function searchOfferAppliesToMovieTicket(params) {
65
68
  throw new factory.errors.NotFound(factory.product.ProductType.EventService);
66
69
  }
67
70
  // const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
68
- const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
71
+ const firstCatalogIdOfProduct = (_d = (_c = eventService.hasOfferCatalog) === null || _c === void 0 ? void 0 : _c.itemListElement.at(0)) === null || _d === void 0 ? void 0 : _d.id;
69
72
  if (typeof firstCatalogIdOfProduct === 'string') {
70
73
  catalogId = firstCatalogIdOfProduct;
71
74
  }
@@ -83,7 +86,7 @@ function searchOfferAppliesToMovieTicket(params) {
83
86
  }
84
87
  return repos.offer.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
85
88
  subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
86
- availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
89
+ availableAtOrFrom: { id: (_e = params.store) === null || _e === void 0 ? void 0 : _e.id },
87
90
  unacceptedPaymentMethod: unacceptedPaymentMethod,
88
91
  excludeAppliesToMovieTicket: excludeAppliesToMovieTicket,
89
92
  onlyValid: params.onlyValid === true,
@@ -110,7 +110,7 @@ function searchTicketOffersByItemOffered(params) {
110
110
  function searchEventTicketOffersByEvent(params) {
111
111
  // tslint:disable-next-line:max-func-body-length
112
112
  return (repos) => __awaiter(this, void 0, void 0, function* () {
113
- var _a;
113
+ var _a, _b;
114
114
  const event = params.event;
115
115
  let soundFormatTypes = [];
116
116
  let videoFormatTypes = [];
@@ -120,13 +120,16 @@ function searchEventTicketOffersByEvent(params) {
120
120
  page: 1,
121
121
  id: { $eq: event.superEvent.id }
122
122
  // typeOf: factory.eventType.ScreeningEventSeries
123
- }, ['soundFormat', 'videoFormat', 'subEvent']);
123
+ },
124
+ // ['soundFormat', 'videoFormat', 'subEvent']
125
+ ['soundFormat', 'subEvent']);
124
126
  const superEvent = superEvents.shift();
125
127
  if (superEvent === undefined) {
126
128
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
127
129
  }
128
130
  soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
129
- videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
131
+ // videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
132
+ videoFormatTypes = (Array.isArray((_a = superEvent.subEvent) === null || _a === void 0 ? void 0 : _a.videoFormat)) ? superEvent.subEvent.videoFormat : [];
130
133
  }
131
134
  const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
132
135
  // 上映方式がなければMovieTicket除外(2023-02-21~)
@@ -134,7 +137,7 @@ function searchEventTicketOffersByEvent(params) {
134
137
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
135
138
  const eventOffers = event.offers;
136
139
  const { availableOffers } = yield searchTicketOffersByItemOffered({
137
- itemOffered: { id: String((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) },
140
+ itemOffered: { id: String((_b = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _b === void 0 ? void 0 : _b.id) },
138
141
  ids: params.ids,
139
142
  store: params.store,
140
143
  // limit: params.limit,
@@ -165,15 +165,17 @@ function createInformTasks(params, setting) {
165
165
  id: { $in: params.ids }
166
166
  // typeOf: params.typeOf
167
167
  }, [
168
- 'project', 'organizer', 'typeOf', 'name', 'location', 'videoFormat', 'soundFormat', 'workPerformed', 'kanaName', 'eventStatus',
168
+ 'project', 'organizer', 'typeOf', 'name', 'location', 'soundFormat', 'workPerformed', 'kanaName', 'eventStatus',
169
169
  'endDate', 'startDate', 'additionalProperty', 'subtitleLanguage', 'dubLanguage',
170
170
  'alternativeHeadline', 'description', 'duration', 'headline', 'subEvent'
171
171
  ] // inclusion(2024-07-30~)
172
172
  );
173
173
  // 最適化(2024-03-25~)
174
- events4inform = screeningEventSeries4inform.map(({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus, endDate, startDate, additionalProperty, subtitleLanguage, dubLanguage, alternativeHeadline, description, duration, headline }) => {
175
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus,
176
- endDate, startDate }, (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (subtitleLanguage !== undefined) ? {} : undefined), (dubLanguage !== undefined) ? { dubLanguage } : undefined), (alternativeHeadline !== undefined) ? { alternativeHeadline } : undefined), (description !== undefined) ? { description } : undefined), (typeof duration === 'string') ? { duration } : undefined), (headline !== undefined) ? { headline } : undefined);
174
+ events4inform = screeningEventSeries4inform.map(({ project, organizer, typeOf, name, location, id, soundFormat, workPerformed, kanaName, eventStatus, endDate, startDate, additionalProperty, subtitleLanguage, dubLanguage, alternativeHeadline, description, duration, headline, subEvent }) => {
175
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ project, organizer, typeOf, name, location, id, soundFormat, workPerformed, kanaName, eventStatus,
176
+ endDate, startDate, videoFormat: (Array.isArray(subEvent === null || subEvent === void 0 ? void 0 : subEvent.videoFormat))
177
+ ? subEvent.videoFormat.map((codeValue) => ({ typeOf: codeValue, name: codeValue }))
178
+ : [] }, (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (subtitleLanguage !== undefined) ? {} : undefined), (dubLanguage !== undefined) ? { dubLanguage } : undefined), (alternativeHeadline !== undefined) ? { alternativeHeadline } : undefined), (description !== undefined) ? { description } : undefined), (typeof duration === 'string') ? { duration } : undefined), (headline !== undefined) ? { headline } : undefined);
177
179
  });
178
180
  }
179
181
  if (events4inform.length > 0) {
package/package.json CHANGED
@@ -116,5 +116,5 @@
116
116
  "postversion": "git push origin --tags",
117
117
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
118
118
  },
119
- "version": "23.2.0-alpha.13"
119
+ "version": "23.2.0-alpha.14"
120
120
  }