@chevre/domain 22.13.0-alpha.5 → 22.13.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/event/migrateEventIdentifier4ttts.ts +11 -11
- package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +192 -0
- package/lib/chevre/repo/event.d.ts +21 -2
- package/lib/chevre/repo/event.js +74 -4
- package/lib/chevre/service/event.d.ts +4 -33
- package/lib/chevre/service/event.js +0 -55
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.d.ts +15 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +386 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +61 -325
- package/package.json +2 -2
- package/example/src/chevre/cancelEvent.ts +0 -22
|
@@ -11,349 +11,85 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createEventBySchedule = createEventBySchedule;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
|
-
// import * as fs from 'fs';
|
|
15
|
-
const moment = require("moment-timezone");
|
|
16
14
|
const factory = require("../../../factory");
|
|
15
|
+
const onEventChanged_1 = require("../../offer/onEventChanged");
|
|
17
16
|
// import { Settings } from '../../../settings';
|
|
18
|
-
const
|
|
19
|
-
const debug = createDebug('chevre-domain:service:task');
|
|
17
|
+
const schedule2events_1 = require("./createEventBySchedule/schedule2events");
|
|
18
|
+
const debug = createDebug('chevre-domain:service:task:createEvent');
|
|
19
|
+
/**
|
|
20
|
+
* イベントコード指定でtttsイベントを冪等更新する
|
|
21
|
+
*/
|
|
22
|
+
function updateEvent4ttts(params) {
|
|
23
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const updateObject = {
|
|
25
|
+
id: params.attributes.identifier,
|
|
26
|
+
identifier: params.attributes.identifier, // support identifier(2025-09-03~)
|
|
27
|
+
typeOf: factory.eventType.ScreeningEvent
|
|
28
|
+
};
|
|
29
|
+
const actionAttributes = {
|
|
30
|
+
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
31
|
+
typeOf: factory.actionType.UpdateAction,
|
|
32
|
+
agent: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
33
|
+
object: updateObject,
|
|
34
|
+
// replacee: reservation,
|
|
35
|
+
// replacer: params.attributes, // $unsetもありうるのでいったん保留
|
|
36
|
+
targetCollection: {
|
|
37
|
+
id: params.attributes.identifier,
|
|
38
|
+
typeOf: factory.eventType.ScreeningEvent
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const action = yield repos.action.start(actionAttributes);
|
|
42
|
+
let savedEvent;
|
|
43
|
+
try {
|
|
44
|
+
savedEvent = yield repos.event.saveEventByIdentifier4ttts({
|
|
45
|
+
// oldEventId: params.oldEventId,
|
|
46
|
+
attributes: params.attributes
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
try {
|
|
51
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
52
|
+
}
|
|
53
|
+
catch (__) {
|
|
54
|
+
// 失敗したら仕方ない
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: savedEvent.id } });
|
|
59
|
+
yield (0, onEventChanged_1.onEventChanged)({
|
|
60
|
+
id: [savedEvent.id],
|
|
61
|
+
project: { id: params.project.id },
|
|
62
|
+
typeOf: factory.eventType.ScreeningEvent,
|
|
63
|
+
isNew: false,
|
|
64
|
+
useInform: true
|
|
65
|
+
})(repos
|
|
66
|
+
// スケジュールによるイベント作成ではendDateに変更がないのでpendingReservationsへの同期はひとまず必要なし
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
20
70
|
function createEvents(
|
|
21
71
|
// schedule: factory.schedule.ISchedule4ttts | factory.schedule.IEventWithSchedule,
|
|
22
72
|
schedule, createDate) {
|
|
23
|
-
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
24
73
|
return (repos
|
|
25
74
|
// settings: Settings
|
|
26
75
|
) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// return;
|
|
30
|
-
const eventServiceId = (_b = (_a = schedule.offers) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
|
|
31
|
-
const makesOffer = (_d = (_c = schedule.offers) === null || _c === void 0 ? void 0 : _c.seller) === null || _d === void 0 ? void 0 : _d.makesOffer;
|
|
32
|
-
const applicationIds = (Array.isArray(makesOffer))
|
|
33
|
-
? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
|
|
34
|
-
: [];
|
|
35
|
-
const eventSeriesId = (_e = schedule.superEvent) === null || _e === void 0 ? void 0 : _e.id;
|
|
36
|
-
if (typeof eventServiceId !== 'string' || eventServiceId === '') {
|
|
37
|
-
throw new factory.errors.NotFound('schedule.offers.itemOffered.id');
|
|
38
|
-
}
|
|
39
|
-
if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
|
|
40
|
-
throw new factory.errors.NotFound('schedule.superEvent.id');
|
|
41
|
-
}
|
|
42
|
-
const project = schedule.project;
|
|
43
|
-
// 引数情報取得
|
|
44
|
-
if (schedule.eventSchedule === undefined) {
|
|
45
|
-
throw new factory.errors.NotFound('eventSchedule');
|
|
46
|
-
}
|
|
47
|
-
const targetInfo = getTargetInfoByEventWithSchedule(schedule, createDate);
|
|
48
|
-
debug(targetInfo.length, 'targetInfos ->', targetInfo);
|
|
49
|
-
// fs.writeFileSync(
|
|
50
|
-
// `${__dirname}/../../../../../targetInfo_${schedule.eventSchedule?.typeOf}.json`,
|
|
51
|
-
// JSON.stringify(targetInfo, null, ' ')
|
|
52
|
-
// );
|
|
53
|
-
// return;
|
|
54
|
-
// 施設コンテンツ検索
|
|
55
|
-
const screeningEventSeries = (yield repos.eventSeries.projectEventSeriesFields({
|
|
56
|
-
project: { id: { $eq: project.id } },
|
|
57
|
-
id: { $eq: eventSeriesId }
|
|
58
|
-
}, [
|
|
59
|
-
'location', 'additionalProperty', 'description', 'endDate', 'headline', 'kanaName', 'name',
|
|
60
|
-
'soundFormat', 'startDate', 'typeOf', 'videoFormat', 'workPerformed'
|
|
61
|
-
])).shift();
|
|
62
|
-
if (screeningEventSeries === undefined) {
|
|
63
|
-
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
64
|
-
}
|
|
65
|
-
const workPerformedIdentifier = screeningEventSeries.workPerformed.identifier;
|
|
66
|
-
// 劇場検索
|
|
67
|
-
const movieTheaters = yield repos.movieTheater.projectFields({
|
|
68
|
-
limit: 1,
|
|
69
|
-
page: 1,
|
|
70
|
-
project: { id: { $eq: project.id } },
|
|
71
|
-
branchCode: { $eq: screeningEventSeries.location.branchCode }
|
|
72
|
-
}, ['id', 'branchCode', 'offers', 'parentOrganization']);
|
|
73
|
-
const movieTheater = movieTheaters.shift();
|
|
74
|
-
if (movieTheater === undefined) {
|
|
75
|
-
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
76
|
-
}
|
|
77
|
-
const seller = movieTheater.parentOrganization;
|
|
78
|
-
const screeningRooms = yield repos.screeningRoom.searchScreeningRooms({
|
|
79
|
-
limit: 1,
|
|
80
|
-
page: 1,
|
|
81
|
-
project: { id: { $eq: project.id } },
|
|
82
|
-
containedInPlace: { id: { $eq: movieTheater.id } }
|
|
83
|
-
});
|
|
84
|
-
const screeningRoom = screeningRooms.shift();
|
|
85
|
-
if (screeningRoom === undefined) {
|
|
86
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
87
|
-
}
|
|
88
|
-
// 興行検索
|
|
89
|
-
// const eventServiceProductID = schedule.eventServiceProductID; // 興行設定に変更(2023-09-24~)
|
|
90
|
-
const searchEventServicesResult = yield repos.product.projectFields({
|
|
91
|
-
limit: 1,
|
|
92
|
-
page: 1,
|
|
93
|
-
project: { id: { $eq: project.id } },
|
|
94
|
-
id: { $eq: eventServiceId }
|
|
95
|
-
// productID: { $eq: eventServiceProductID }
|
|
96
|
-
}, ['name']);
|
|
97
|
-
const eventService = searchEventServicesResult.shift();
|
|
98
|
-
if (typeof (eventService === null || eventService === void 0 ? void 0 : eventService.id) !== 'string') {
|
|
99
|
-
throw new Error(`EventService ${eventServiceId} not found`);
|
|
100
|
-
}
|
|
101
|
-
let existingApplicationMembers = [];
|
|
102
|
-
if (applicationIds.length > 0) {
|
|
103
|
-
existingApplicationMembers = yield repos.member.searchCustomerMembers({
|
|
104
|
-
limit: 100,
|
|
105
|
-
page: 1,
|
|
106
|
-
project: { id: project.id },
|
|
107
|
-
member: {
|
|
108
|
-
// typeOf: {
|
|
109
|
-
// $eq: factory.creativeWorkType.WebApplication
|
|
110
|
-
// },
|
|
111
|
-
id: { $in: applicationIds }
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
// ロールで絞る(customer or pos)
|
|
116
|
-
// existingApplicationMembers = existingApplicationMembers
|
|
117
|
-
// .filter((m) => {
|
|
118
|
-
// return Array.isArray(m.member.hasRole) && m.member.hasRole.some((r) => AVAILABLE_ROLE_NAMES.includes(r.roleName));
|
|
119
|
-
// });
|
|
120
|
-
for (const performanceInfo of targetInfo) {
|
|
121
|
-
const oldEventId = [
|
|
122
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
123
|
-
performanceInfo.day.slice(-6),
|
|
124
|
-
workPerformedIdentifier,
|
|
125
|
-
movieTheater.branchCode,
|
|
126
|
-
screeningRoom.branchCode,
|
|
127
|
-
performanceInfo.start_time
|
|
128
|
-
].join('');
|
|
129
|
-
const maxValue = (_g = (_f = movieTheater.offers) === null || _f === void 0 ? void 0 : _f.eligibleQuantity) === null || _g === void 0 ? void 0 : _g.maxValue;
|
|
130
|
-
const availabilityEnds = moment(performanceInfo.end_date)
|
|
131
|
-
.tz('Asia/Tokyo')
|
|
132
|
-
.endOf('date')
|
|
133
|
-
.toDate();
|
|
134
|
-
const availabilityStarts = moment(performanceInfo.start_date)
|
|
135
|
-
.tz('Asia/Tokyo')
|
|
136
|
-
.startOf('date')
|
|
137
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
138
|
-
.add(-3, 'months')
|
|
139
|
-
.toDate();
|
|
140
|
-
const validThrough = moment(performanceInfo.end_date)
|
|
141
|
-
.tz('Asia/Tokyo')
|
|
142
|
-
.endOf('date')
|
|
143
|
-
.toDate();
|
|
144
|
-
const validFrom = moment(performanceInfo.start_date)
|
|
145
|
-
.tz('Asia/Tokyo')
|
|
146
|
-
.startOf('date')
|
|
147
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
148
|
-
.add(-3, 'months')
|
|
149
|
-
.toDate();
|
|
150
|
-
const offersSeller = {
|
|
151
|
-
typeOf: factory.organizationType.Corporation,
|
|
152
|
-
id: String(seller === null || seller === void 0 ? void 0 : seller.id),
|
|
153
|
-
// event.offersにseller.makesOfferを追加(2022-11-18~)
|
|
154
|
-
makesOffer: existingApplicationMembers.map((a) => {
|
|
155
|
-
return {
|
|
156
|
-
typeOf: factory.offerType.Offer,
|
|
157
|
-
availableAtOrFrom: { id: a.member.id }, // support no-array(2024-10-13~),
|
|
158
|
-
availabilityEnds,
|
|
159
|
-
availabilityStarts,
|
|
160
|
-
validFrom,
|
|
161
|
-
validThrough
|
|
162
|
-
};
|
|
163
|
-
})
|
|
164
|
-
};
|
|
165
|
-
const offers = Object.assign({ typeOf: factory.offerType.Offer, eligibleQuantity: Object.assign({ typeOf: 'QuantitativeValue', unitCode: factory.unitCode.C62 }, (typeof maxValue === 'number') ? { maxValue } : undefined // ひとまず全座席予約可能なように
|
|
166
|
-
), itemOffered: Object.assign({
|
|
167
|
-
// 興行ID追加(2022-09-01~)
|
|
168
|
-
id: eventService.id, serviceOutput: {
|
|
169
|
-
typeOf: factory.reservationType.EventReservation,
|
|
170
|
-
reservedTicket: {
|
|
171
|
-
typeOf: 'Ticket',
|
|
172
|
-
ticketedSeat: { typeOf: factory.placeType.Seat }
|
|
173
|
-
}
|
|
174
|
-
}, typeOf: factory.product.ProductType.EventService, availableChannel: {
|
|
175
|
-
typeOf: 'ServiceChannel',
|
|
176
|
-
serviceLocation: {
|
|
177
|
-
typeOf: screeningRoom.typeOf,
|
|
178
|
-
branchCode: screeningRoom.branchCode,
|
|
179
|
-
name: screeningRoom.name,
|
|
180
|
-
containedInPlace: Object.assign({ typeOf: screeningEventSeries.location.typeOf, id: screeningEventSeries.location.id, branchCode: screeningEventSeries.location.branchCode }, (screeningEventSeries.location.name !== undefined)
|
|
181
|
-
? { name: screeningEventSeries.location.name }
|
|
182
|
-
: undefined)
|
|
183
|
-
}
|
|
184
|
-
} }, { name: { ja: (typeof eventService.name === 'string') ? eventService.name : String((_h = eventService.name) === null || _h === void 0 ? void 0 : _h.ja) } }), seller: offersSeller }, {
|
|
185
|
-
// availabilityEnds, // discontinue(2024-10-16~)
|
|
186
|
-
// availabilityStarts,
|
|
187
|
-
// validThrough,
|
|
188
|
-
// validFrom
|
|
189
|
-
});
|
|
190
|
-
const screeningEventSuperEvent = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: screeningEventSeries.typeOf, id: screeningEventSeries.id, videoFormat: screeningEventSeries.videoFormat, soundFormat: screeningEventSeries.soundFormat, workPerformed: screeningEventSeries.workPerformed, location: screeningEventSeries.location, kanaName: screeningEventSeries.kanaName, name: screeningEventSeries.name }, (Array.isArray(screeningEventSeries.additionalProperty))
|
|
191
|
-
? { additionalProperty: screeningEventSeries.additionalProperty }
|
|
192
|
-
: undefined), (screeningEventSeries.startDate !== undefined)
|
|
193
|
-
? { startDate: screeningEventSeries.startDate }
|
|
194
|
-
: undefined), (screeningEventSeries.endDate !== undefined)
|
|
195
|
-
? { endDate: screeningEventSeries.endDate }
|
|
196
|
-
: undefined), (screeningEventSeries.description !== undefined)
|
|
197
|
-
? { description: screeningEventSeries.description }
|
|
198
|
-
: undefined), (screeningEventSeries.headline !== undefined)
|
|
199
|
-
? { headline: screeningEventSeries.headline }
|
|
200
|
-
: undefined);
|
|
201
|
-
// イベント作成
|
|
202
|
-
const eventAttributes = {
|
|
203
|
-
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
204
|
-
typeOf: factory.eventType.ScreeningEvent,
|
|
205
|
-
eventStatus: factory.eventStatusType.EventScheduled,
|
|
206
|
-
name: screeningEventSeries.name,
|
|
207
|
-
doorTime: performanceInfo.door_time,
|
|
208
|
-
startDate: performanceInfo.start_date,
|
|
209
|
-
endDate: performanceInfo.end_date,
|
|
210
|
-
superEvent: screeningEventSuperEvent,
|
|
211
|
-
location: Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name }, (screeningRoom.address !== undefined) ? { address: screeningRoom.address } : undefined),
|
|
212
|
-
offers: offers,
|
|
213
|
-
// checkInCount: undefined,
|
|
214
|
-
// attendeeCount: undefined,
|
|
215
|
-
// 旧フォーマットIDを追加特性に追加(2022-09-08~)
|
|
216
|
-
additionalProperty: [
|
|
217
|
-
{ name: 'tourNumber', value: String(performanceInfo.tour_number) },
|
|
218
|
-
{ name: 'oldEventId', value: oldEventId }
|
|
219
|
-
],
|
|
220
|
-
// organizer追加(2023-07-12~)
|
|
221
|
-
organizer: { id: seller.id }
|
|
222
|
-
};
|
|
76
|
+
const creatingEvents = yield (0, schedule2events_1.schedule2events)(schedule, createDate)(repos);
|
|
77
|
+
for (const eventAttributes of creatingEvents) {
|
|
223
78
|
// domain.serviceで実装(2022-09-10~)
|
|
224
|
-
debug('updating event...',
|
|
225
|
-
yield
|
|
226
|
-
oldEventId,
|
|
79
|
+
debug('updating event...', eventAttributes.identifier, eventAttributes.startDate);
|
|
80
|
+
yield updateEvent4ttts({
|
|
81
|
+
// oldEventId,
|
|
227
82
|
attributes: eventAttributes,
|
|
228
83
|
project: { id: eventAttributes.project.id }
|
|
229
84
|
// agent: eventAttributes.project
|
|
230
85
|
})(repos
|
|
231
86
|
// settings
|
|
232
87
|
);
|
|
233
|
-
debug('event update(updateEvent4ttts)',
|
|
88
|
+
debug('event update(updateEvent4ttts)', eventAttributes.identifier, eventAttributes.startDate);
|
|
234
89
|
}
|
|
235
|
-
debug(
|
|
90
|
+
debug(creatingEvents.length, 'events updated');
|
|
236
91
|
});
|
|
237
92
|
}
|
|
238
|
-
/**
|
|
239
|
-
* パフォーマンス作成・作成対象情報取得
|
|
240
|
-
*/
|
|
241
|
-
// function getTargetInfoForCreateFromSetting(
|
|
242
|
-
// settings: factory.schedule.ISchedule4ttts,
|
|
243
|
-
// createDate: Date
|
|
244
|
-
// ): ITargetPerformanceInfo[] {
|
|
245
|
-
// const performanceInfos: ITargetPerformanceInfo[] = [];
|
|
246
|
-
// const { days, duration, noPerformanceTimes, hours, minutes, tours } = settings;
|
|
247
|
-
// // 本日日付+開始日までの日数から作成開始日セット
|
|
248
|
-
// // 作成日数分の作成対象日付作成
|
|
249
|
-
// for (let index = 0; index < days; index = index + 1) {
|
|
250
|
-
// const now = (createDate instanceof Date)
|
|
251
|
-
// ? moment(createDate)
|
|
252
|
-
// .add(index, 'days')
|
|
253
|
-
// : moment()
|
|
254
|
-
// .add(index, 'days');
|
|
255
|
-
// hours.forEach((hourStr) => {
|
|
256
|
-
// // 2桁でない時は'0'詰め
|
|
257
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
258
|
-
// const hour = `0${hourStr}`.slice(-2);
|
|
259
|
-
// minutes.forEach((minute, minuteIndex) => {
|
|
260
|
-
// // ツアー情報作成
|
|
261
|
-
// const tourNumber = `${hour}${tours[minuteIndex]}`;
|
|
262
|
-
// const startDate = moment(
|
|
263
|
-
// `${now.tz('Asia/Tokyo')
|
|
264
|
-
// .format('YYYYMMDD')} ${hour}:${minute}:00+09:00`,
|
|
265
|
-
// 'YYYYMMDD HH:mm:ssZ'
|
|
266
|
-
// );
|
|
267
|
-
// const endDate = moment(startDate)
|
|
268
|
-
// .add(duration, 'minutes');
|
|
269
|
-
// const day = moment(startDate)
|
|
270
|
-
// .tz('Asia/Tokyo')
|
|
271
|
-
// .format('YYYYMMDD');
|
|
272
|
-
// const startTime = moment(startDate)
|
|
273
|
-
// .tz('Asia/Tokyo')
|
|
274
|
-
// .format('HHmm');
|
|
275
|
-
// const endTime = moment(endDate)
|
|
276
|
-
// .tz('Asia/Tokyo')
|
|
277
|
-
// .format('HHmm');
|
|
278
|
-
// // パフォーマンスを作成しない時刻に指定されていなかったら作成
|
|
279
|
-
// if (noPerformanceTimes.indexOf(`${hour}${minute}`) < 0) {
|
|
280
|
-
// performanceInfos.push({
|
|
281
|
-
// day: day,
|
|
282
|
-
// start_time: startTime,
|
|
283
|
-
// end_time: endTime,
|
|
284
|
-
// door_time: startDate.toDate(),
|
|
285
|
-
// start_date: startDate.toDate(),
|
|
286
|
-
// end_date: endDate.toDate(),
|
|
287
|
-
// tour_number: tourNumber,
|
|
288
|
-
// duration: moment.duration(duration, 'minutes')
|
|
289
|
-
// .toISOString()
|
|
290
|
-
// });
|
|
291
|
-
// }
|
|
292
|
-
// });
|
|
293
|
-
// });
|
|
294
|
-
// }
|
|
295
|
-
// return performanceInfos;
|
|
296
|
-
// }
|
|
297
|
-
function getTargetInfoByEventWithSchedule(settings, createDate) {
|
|
298
|
-
const performanceInfos = [];
|
|
299
|
-
const { eventSchedule } = settings;
|
|
300
|
-
// 作成対象時間: 9,10,11など
|
|
301
|
-
// const hours: string[] = ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'];
|
|
302
|
-
// const minutes = ['00', '15', '30', '45'];
|
|
303
|
-
// const tours = ['1', '2', '3', '4'];
|
|
304
|
-
// 1日分作成する
|
|
305
|
-
const now = (createDate instanceof Date)
|
|
306
|
-
? moment(createDate)
|
|
307
|
-
: moment();
|
|
308
|
-
let startDate = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
|
|
309
|
-
.format('YYYYMMDD')} ${eventSchedule.startTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
|
|
310
|
-
const startDateShouldBeLte = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
|
|
311
|
-
.format('YYYYMMDD')} ${eventSchedule.endTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
|
|
312
|
-
const frequencyInMinutes = moment.duration(eventSchedule.repeatFrequency)
|
|
313
|
-
.asMinutes();
|
|
314
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
315
|
-
const repeatCountInHour = Math.floor(60 / frequencyInMinutes);
|
|
316
|
-
let i = 0;
|
|
317
|
-
while (startDate < startDateShouldBeLte) {
|
|
318
|
-
i += 1;
|
|
319
|
-
if (i > 1) {
|
|
320
|
-
startDate = moment(startDate)
|
|
321
|
-
.add(moment.duration(eventSchedule.repeatFrequency));
|
|
322
|
-
}
|
|
323
|
-
const hour = `0${moment(startDate)
|
|
324
|
-
.format('HH')}`
|
|
325
|
-
// 2桁でない時は'0'詰め
|
|
326
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
327
|
-
.slice(-2);
|
|
328
|
-
let tourIndex = i % repeatCountInHour;
|
|
329
|
-
if (tourIndex === 0) {
|
|
330
|
-
tourIndex = repeatCountInHour;
|
|
331
|
-
}
|
|
332
|
-
const tourNumber = `${hour}${tourIndex}`;
|
|
333
|
-
const endDate = moment(startDate)
|
|
334
|
-
.add(moment.duration(eventSchedule.duration));
|
|
335
|
-
const day = moment(startDate)
|
|
336
|
-
.tz(eventSchedule.scheduleTimezone)
|
|
337
|
-
.format('YYYYMMDD');
|
|
338
|
-
const startTime = moment(startDate)
|
|
339
|
-
.tz(eventSchedule.scheduleTimezone)
|
|
340
|
-
.format('HHmm');
|
|
341
|
-
const endTime = moment(endDate)
|
|
342
|
-
.tz(eventSchedule.scheduleTimezone)
|
|
343
|
-
.format('HHmm');
|
|
344
|
-
performanceInfos.push({
|
|
345
|
-
day: day,
|
|
346
|
-
start_time: startTime,
|
|
347
|
-
end_time: endTime,
|
|
348
|
-
door_time: startDate.toDate(),
|
|
349
|
-
start_date: startDate.toDate(),
|
|
350
|
-
end_date: endDate.toDate(),
|
|
351
|
-
tour_number: tourNumber,
|
|
352
|
-
duration: eventSchedule.duration
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
return performanceInfos;
|
|
356
|
-
}
|
|
357
93
|
function createEventBySchedule(params) {
|
|
358
94
|
return (repos
|
|
359
95
|
// settings: Settings
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.398.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.398.0-alpha.4",
|
|
15
15
|
"@cinerino/sdk": "12.2.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "22.13.0-alpha.
|
|
118
|
+
"version": "22.13.0-alpha.7"
|
|
119
119
|
}
|
|
@@ -1,22 +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);
|
|
10
|
-
|
|
11
|
-
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const result = await eventRepo.cancelEvent({
|
|
14
|
-
project: { id: project.id },
|
|
15
|
-
id: '7iri6w0m1h1hu5y'
|
|
16
|
-
});
|
|
17
|
-
console.log(result);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
main()
|
|
21
|
-
.then()
|
|
22
|
-
.catch(console.error);
|