@chevre/domain 27.1.0-alpha.2 → 27.1.0-alpha.4
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/lib/chevre/repo/adminEvent.d.ts +236 -0
- package/lib/chevre/repo/adminEvent.js +388 -0
- package/lib/chevre/repo/aggregateEvent.d.ts +42 -0
- package/lib/chevre/repo/aggregateEvent.js +221 -0
- package/lib/chevre/repo/event.d.ts +5 -263
- package/lib/chevre/repo/event.js +31 -664
- package/lib/chevre/repo/eventSeries.js +24 -24
- package/lib/chevre/repository.d.ts +10 -0
- package/lib/chevre/repository.js +24 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/aggregation/event/importFromCOA.d.ts +2 -2
- package/lib/chevre/service/aggregation/event/importFromCOA.js +1 -1
- package/lib/chevre/service/aggregation/system.d.ts +2 -2
- package/lib/chevre/service/aggregation/system.js +1 -1
- package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -2
- package/lib/chevre/service/event/saveScreeningEvents.js +1 -1
- package/lib/chevre/service/event.d.ts +2 -0
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +2 -3
- package/lib/chevre/service/offer/onEventChanged.d.ts +2 -0
- package/lib/chevre/service/offer/onEventChanged.js +1 -1
- package/lib/chevre/service/project.d.ts +3 -3
- package/lib/chevre/service/project.js +1 -1
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -0
- package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +2 -2
- package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
- package/lib/chevre/service/task/onEventChanged.js +2 -0
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +2 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +1 -1
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +2 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +1 -1
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +2 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +1 -1
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +2 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +1 -1
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +2 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +1 -1
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +2 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +1 -1
- package/lib/chevre/service/task/onResourceDeleted.js +2 -2
- package/lib/chevre/service/task/syncResourcesFromCOA.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Connection, FilterQuery, mongo } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
export interface IAttributes4patchUpdate {
|
|
4
|
+
typeOf: factory.eventType.ScreeningEvent;
|
|
5
|
+
eventStatus?: factory.eventStatusType;
|
|
6
|
+
}
|
|
7
|
+
export interface IUpdateAggregateReservationParams {
|
|
8
|
+
$set: {
|
|
9
|
+
aggregateReservation: factory.event.screeningEvent.IAggregateReservation;
|
|
10
|
+
aggregateOffer?: Pick<factory.event.screeningEvent.IAggregateOffer, 'aggregateDate' | 'offerCount' | 'typeOf'>;
|
|
11
|
+
maximumAttendeeCapacity?: number;
|
|
12
|
+
remainingAttendeeCapacity?: number;
|
|
13
|
+
checkInCount?: number;
|
|
14
|
+
attendeeCount?: number;
|
|
15
|
+
};
|
|
16
|
+
$unset: {
|
|
17
|
+
noExistingAttributeName: 1;
|
|
18
|
+
maximumAttendeeCapacity?: '';
|
|
19
|
+
remainingAttendeeCapacity?: '';
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
type IUnset = {
|
|
23
|
+
[key in keyof factory.event.screeningEvent.IEvent]?: 1;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* イベント管理リポジトリ
|
|
27
|
+
*/
|
|
28
|
+
export declare class AdminEventRepo {
|
|
29
|
+
private readonly eventModel;
|
|
30
|
+
constructor(connection: Connection);
|
|
31
|
+
/**
|
|
32
|
+
* イベントIDを生成する
|
|
33
|
+
*/
|
|
34
|
+
static CREATE_ID(): string;
|
|
35
|
+
/**
|
|
36
|
+
* イベントコードをキーにして冪等置換
|
|
37
|
+
*/
|
|
38
|
+
upsertManyScreeningEventByIdentifier(params: {
|
|
39
|
+
$set: factory.event.screeningEvent.IAttributes & {
|
|
40
|
+
id?: never;
|
|
41
|
+
};
|
|
42
|
+
$unset: IUnset;
|
|
43
|
+
}[], options: {
|
|
44
|
+
/**
|
|
45
|
+
* falseの場合setOnInsertのみ
|
|
46
|
+
* trueの場合setのみ
|
|
47
|
+
*/
|
|
48
|
+
update: boolean;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
bulkWriteResult?: mongo.BulkWriteResult;
|
|
51
|
+
modifiedEvents: {
|
|
52
|
+
id: string;
|
|
53
|
+
}[];
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* イベント部分更新
|
|
57
|
+
*/
|
|
58
|
+
updatePartiallyById(params: {
|
|
59
|
+
project: {
|
|
60
|
+
id: string;
|
|
61
|
+
};
|
|
62
|
+
id: string;
|
|
63
|
+
attributes: IAttributes4patchUpdate;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* 単一イベント編集
|
|
67
|
+
*/
|
|
68
|
+
updateEventById(params: {
|
|
69
|
+
id: string;
|
|
70
|
+
attributes: factory.event.screeningEvent.IAttributes & {
|
|
71
|
+
id?: never;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* ドキュメント作成時には無視される
|
|
75
|
+
*/
|
|
76
|
+
$unset?: IUnset;
|
|
77
|
+
}): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* sskts専用
|
|
80
|
+
*/
|
|
81
|
+
saveManyEvents(params: {
|
|
82
|
+
id: string;
|
|
83
|
+
attributes: factory.event.screeningEvent.IAttributes;
|
|
84
|
+
$unset?: IUnset;
|
|
85
|
+
upsert: boolean;
|
|
86
|
+
}[]): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* イベントをキャンセルする
|
|
89
|
+
*/
|
|
90
|
+
cancelEvent(params: {
|
|
91
|
+
project: {
|
|
92
|
+
id: string;
|
|
93
|
+
};
|
|
94
|
+
id: string;
|
|
95
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
96
|
+
/**
|
|
97
|
+
* 興行イベントのsuperEventを最新の情報に同期する
|
|
98
|
+
*/
|
|
99
|
+
syncScreeningEventSeries2screeningEvents(params: {
|
|
100
|
+
project: {
|
|
101
|
+
id: string;
|
|
102
|
+
};
|
|
103
|
+
superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'workPerformed'>;
|
|
104
|
+
startDate: {
|
|
105
|
+
$gte: Date;
|
|
106
|
+
};
|
|
107
|
+
}): Promise<void>;
|
|
108
|
+
deleteEventById(params: {
|
|
109
|
+
project: {
|
|
110
|
+
id: string;
|
|
111
|
+
};
|
|
112
|
+
id: string;
|
|
113
|
+
}): Promise<void>;
|
|
114
|
+
deleteManyEventByOrganizerId(params: {
|
|
115
|
+
project: {
|
|
116
|
+
id: string;
|
|
117
|
+
};
|
|
118
|
+
organizer: {
|
|
119
|
+
id: string;
|
|
120
|
+
};
|
|
121
|
+
}): Promise<mongo.DeleteResult>;
|
|
122
|
+
deleteManyEventsByScreeningRoom(params: {
|
|
123
|
+
project: {
|
|
124
|
+
id: string;
|
|
125
|
+
};
|
|
126
|
+
location: {
|
|
127
|
+
/**
|
|
128
|
+
* ルームコード
|
|
129
|
+
*/
|
|
130
|
+
branchCode: string;
|
|
131
|
+
containedInPlace: {
|
|
132
|
+
/**
|
|
133
|
+
* 施設ID
|
|
134
|
+
*/
|
|
135
|
+
id: string;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
}): Promise<mongo.DeleteResult>;
|
|
139
|
+
deleteManyBySuperEventId(params: {
|
|
140
|
+
project: {
|
|
141
|
+
id: string;
|
|
142
|
+
};
|
|
143
|
+
superEvent: {
|
|
144
|
+
id: string;
|
|
145
|
+
};
|
|
146
|
+
}): Promise<mongo.DeleteResult>;
|
|
147
|
+
deleteManyBySuperEventLocationId(params: {
|
|
148
|
+
project: {
|
|
149
|
+
id: string;
|
|
150
|
+
};
|
|
151
|
+
superEvent: {
|
|
152
|
+
location: {
|
|
153
|
+
id: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
}): Promise<mongo.DeleteResult>;
|
|
157
|
+
/**
|
|
158
|
+
* 興行(プロダクト)から削除する
|
|
159
|
+
*/
|
|
160
|
+
deleteManyEventsByItemOfferedId(params: {
|
|
161
|
+
project: {
|
|
162
|
+
id: string;
|
|
163
|
+
};
|
|
164
|
+
offers: {
|
|
165
|
+
itemOffered: {
|
|
166
|
+
id: {
|
|
167
|
+
$in: string[];
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
}): Promise<mongo.DeleteResult>;
|
|
172
|
+
deleteManyEventsEndedByProject(params: {
|
|
173
|
+
typeOf: {
|
|
174
|
+
$in: factory.eventType.ScreeningEvent[];
|
|
175
|
+
};
|
|
176
|
+
project: {
|
|
177
|
+
id: string;
|
|
178
|
+
};
|
|
179
|
+
endDate: {
|
|
180
|
+
$lte: Date;
|
|
181
|
+
};
|
|
182
|
+
}): Promise<mongo.DeleteResult>;
|
|
183
|
+
deleteManyEventsEnded(params: {
|
|
184
|
+
typeOf: {
|
|
185
|
+
$eq: factory.eventType.ScreeningEvent;
|
|
186
|
+
};
|
|
187
|
+
endDate: {
|
|
188
|
+
$lte: Date;
|
|
189
|
+
};
|
|
190
|
+
}): Promise<mongo.DeleteResult>;
|
|
191
|
+
deleteByProject(params: {
|
|
192
|
+
project: {
|
|
193
|
+
id: string;
|
|
194
|
+
};
|
|
195
|
+
}): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* 集計属性を更新する
|
|
198
|
+
*/
|
|
199
|
+
updateAggregationById(params: {
|
|
200
|
+
id: string;
|
|
201
|
+
}, update: IUpdateAggregateReservationParams): Promise<void>;
|
|
202
|
+
bulkWrite(bulkWriteOps: any[]): Promise<mongo.BulkWriteResult & {
|
|
203
|
+
mongoose?: {
|
|
204
|
+
validationErrors: import("mongoose").Error[];
|
|
205
|
+
} | undefined;
|
|
206
|
+
}>;
|
|
207
|
+
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, import("@chevre/factory/lib/chevre/event/screeningEvent").IAttributes & {
|
|
208
|
+
_id: string;
|
|
209
|
+
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
210
|
+
}, import("./mongoose/virtuals").IVirtuals, {}> & import("@chevre/factory/lib/chevre/event/screeningEvent").IAttributes & {
|
|
211
|
+
_id: string;
|
|
212
|
+
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
213
|
+
} & Required<{
|
|
214
|
+
_id: string;
|
|
215
|
+
}> & {
|
|
216
|
+
__v: number;
|
|
217
|
+
}, import("mongoose").QueryOptions<import("@chevre/factory/lib/chevre/event/screeningEvent").IAttributes & {
|
|
218
|
+
_id: string;
|
|
219
|
+
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
220
|
+
}>, (import("mongoose").Document<unknown, Record<string, never>, import("@chevre/factory/lib/chevre/event/screeningEvent").IAttributes & {
|
|
221
|
+
_id: string;
|
|
222
|
+
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
223
|
+
}, import("./mongoose/virtuals").IVirtuals, {}> & import("@chevre/factory/lib/chevre/event/screeningEvent").IAttributes & {
|
|
224
|
+
_id: string;
|
|
225
|
+
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
226
|
+
} & Required<{
|
|
227
|
+
_id: string;
|
|
228
|
+
}> & {
|
|
229
|
+
__v: number;
|
|
230
|
+
}) | null>;
|
|
231
|
+
unsetUnnecessaryFields(params: {
|
|
232
|
+
filter: FilterQuery<factory.event.screeningEvent.IEvent>;
|
|
233
|
+
$unset: IUnset;
|
|
234
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
235
|
+
}
|
|
236
|
+
export {};
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AdminEventRepo = void 0;
|
|
37
|
+
const mongoose_1 = require("mongoose");
|
|
38
|
+
const errorHandler_1 = require("../errorHandler");
|
|
39
|
+
const factory_1 = require("../factory");
|
|
40
|
+
const EventFactory = __importStar(require("../factory/event"));
|
|
41
|
+
const event_1 = require("./mongoose/schemas/event");
|
|
42
|
+
// export type ICreatingEvent4ttts = Pick<
|
|
43
|
+
// factory.event.screeningEvent.IAttributes,
|
|
44
|
+
// 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus'
|
|
45
|
+
// | 'location' | 'name' | 'offers' | 'organizer' | 'project' | 'startDate' | 'superEvent' | 'typeOf'
|
|
46
|
+
// > & {
|
|
47
|
+
// identifier: string;
|
|
48
|
+
// };
|
|
49
|
+
/**
|
|
50
|
+
* イベント管理リポジトリ
|
|
51
|
+
*/
|
|
52
|
+
class AdminEventRepo {
|
|
53
|
+
eventModel;
|
|
54
|
+
constructor(connection) {
|
|
55
|
+
this.eventModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* イベントIDを生成する
|
|
59
|
+
*/
|
|
60
|
+
static CREATE_ID() {
|
|
61
|
+
// implement using ObjectId(2025-10-17~)
|
|
62
|
+
// return (USE_OBJECT_ID_AS_EVENT_ID) ? new Types.ObjectId().toHexString() : uniqid();
|
|
63
|
+
return new mongoose_1.Types.ObjectId().toHexString(); // 設定を廃止(2025-11-20~)
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* イベントコードをキーにして冪等置換
|
|
67
|
+
*/
|
|
68
|
+
async upsertManyScreeningEventByIdentifier(params, options) {
|
|
69
|
+
const { update } = options;
|
|
70
|
+
const bulkWriteOps = [];
|
|
71
|
+
const queryFilters = [];
|
|
72
|
+
if (Array.isArray(params)) {
|
|
73
|
+
params.forEach(({ $set, $unset }) => {
|
|
74
|
+
const { project, identifier } = $set;
|
|
75
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
76
|
+
throw new factory_1.factory.errors.ArgumentNull('identifier');
|
|
77
|
+
}
|
|
78
|
+
// リソースのユニークネスを保証するfilter
|
|
79
|
+
const filter = {
|
|
80
|
+
'project.id': { $eq: project.id },
|
|
81
|
+
identifier: { $exists: true, $eq: identifier }
|
|
82
|
+
};
|
|
83
|
+
queryFilters.push({
|
|
84
|
+
'project.id': { $eq: project.id },
|
|
85
|
+
identifier: { $exists: true, $eq: identifier }
|
|
86
|
+
});
|
|
87
|
+
if (update === true) {
|
|
88
|
+
const { maximumPhysicalAttendeeCapacity, additionalProperty, eventStatus, location, name, superEvent, offers, doorTime, endDate, startDate } = $set;
|
|
89
|
+
const setFields = {
|
|
90
|
+
maximumPhysicalAttendeeCapacity, additionalProperty,
|
|
91
|
+
eventStatus, location, name, superEvent, offers,
|
|
92
|
+
doorTime, endDate, startDate
|
|
93
|
+
};
|
|
94
|
+
const updateOne = {
|
|
95
|
+
filter,
|
|
96
|
+
update: {
|
|
97
|
+
$set: setFields,
|
|
98
|
+
...($unset !== undefined) ? { $unset } : undefined
|
|
99
|
+
},
|
|
100
|
+
upsert: false
|
|
101
|
+
};
|
|
102
|
+
bulkWriteOps.push({ updateOne });
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const { id, coaInfo, description, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
106
|
+
maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
107
|
+
...setOnInsertFields } = $set;
|
|
108
|
+
const setOnInsert = {
|
|
109
|
+
...setOnInsertFields,
|
|
110
|
+
identifier,
|
|
111
|
+
_id: AdminEventRepo.CREATE_ID()
|
|
112
|
+
};
|
|
113
|
+
const updateOne = {
|
|
114
|
+
filter,
|
|
115
|
+
update: {
|
|
116
|
+
$setOnInsert: setOnInsert
|
|
117
|
+
},
|
|
118
|
+
upsert: true
|
|
119
|
+
};
|
|
120
|
+
bulkWriteOps.push({ updateOne });
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (bulkWriteOps.length > 0) {
|
|
125
|
+
const bulkWriteResult = await this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
126
|
+
// update:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-16~)
|
|
127
|
+
if (!update) {
|
|
128
|
+
// BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
|
|
129
|
+
return {
|
|
130
|
+
bulkWriteResult,
|
|
131
|
+
modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
|
|
132
|
+
.map((id) => ({ id: String(id) }))
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
137
|
+
const modifiedEvents = await this.eventModel.find({ $or: queryFilters }, {
|
|
138
|
+
_id: 0,
|
|
139
|
+
id: { $toString: '$_id' }
|
|
140
|
+
})
|
|
141
|
+
.lean()
|
|
142
|
+
.exec();
|
|
143
|
+
return { bulkWriteResult, modifiedEvents };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return { modifiedEvents: [] };
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* イベント部分更新
|
|
150
|
+
*/
|
|
151
|
+
async updatePartiallyById(params) {
|
|
152
|
+
// let doc: Document | null;
|
|
153
|
+
const { typeOf, ...updateFields } = params.attributes;
|
|
154
|
+
if (typeof typeOf !== 'string' || typeOf.length === 0) {
|
|
155
|
+
throw new factory_1.factory.errors.ArgumentNull('attributes.typeOf');
|
|
156
|
+
}
|
|
157
|
+
const doc = await this.eventModel.findOneAndUpdate({
|
|
158
|
+
_id: { $eq: params.id },
|
|
159
|
+
'project.id': { $eq: params.project.id },
|
|
160
|
+
typeOf: { $eq: typeOf }
|
|
161
|
+
}, {
|
|
162
|
+
$set: updateFields
|
|
163
|
+
}, { upsert: false, new: false, projection: { _id: 1 } })
|
|
164
|
+
.lean()
|
|
165
|
+
.exec();
|
|
166
|
+
if (doc === null) {
|
|
167
|
+
throw new factory_1.factory.errors.NotFound(this.eventModel.modelName);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 単一イベント編集
|
|
172
|
+
*/
|
|
173
|
+
async updateEventById(params) {
|
|
174
|
+
let doc;
|
|
175
|
+
const { identifier, project, typeOf, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
176
|
+
organizer, aggregateReservation, maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
177
|
+
coaInfo, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
178
|
+
...updateFields
|
|
179
|
+
// maximumPhysicalAttendeeCapacity, additionalProperty,
|
|
180
|
+
// eventStatus, location, name, superEvent, offers,
|
|
181
|
+
// doorTime, endDate, startDate
|
|
182
|
+
} = params.attributes;
|
|
183
|
+
if (typeof typeOf !== 'string' || typeOf.length === 0) {
|
|
184
|
+
throw new factory_1.factory.errors.ArgumentNull('attributes.typeOf');
|
|
185
|
+
}
|
|
186
|
+
if (typeof params.id !== 'string' || params.id === '') {
|
|
187
|
+
throw new factory_1.factory.errors.ArgumentNull('id');
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
doc = await this.eventModel.findOneAndUpdate({
|
|
191
|
+
_id: { $eq: params.id },
|
|
192
|
+
typeOf: { $eq: typeOf }
|
|
193
|
+
}, {
|
|
194
|
+
// 編集のためのみのメソッドになったので、setOnInsertは廃止(2025-10-27~)
|
|
195
|
+
// 上書き禁止属性を除外(2022-08-24~)
|
|
196
|
+
// $setOnInsert: {
|
|
197
|
+
// typeOf,
|
|
198
|
+
// project,
|
|
199
|
+
// ...(typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined
|
|
200
|
+
// },
|
|
201
|
+
$set: updateFields,
|
|
202
|
+
...(params.$unset !== undefined) ? { $unset: params.$unset } : undefined
|
|
203
|
+
}, {
|
|
204
|
+
upsert: false,
|
|
205
|
+
new: true,
|
|
206
|
+
projection: { _id: 1 }
|
|
207
|
+
})
|
|
208
|
+
.lean()
|
|
209
|
+
.exec();
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
if (await (0, errorHandler_1.isMongoDuplicateError)(error)) {
|
|
213
|
+
throw new factory_1.factory.errors.AlreadyInUse(factory_1.factory.eventType.ScreeningEvent, ['offeredBy.member.identifier']);
|
|
214
|
+
}
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
if (doc === null) {
|
|
218
|
+
throw new factory_1.factory.errors.NotFound(this.eventModel.modelName);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* sskts専用
|
|
223
|
+
*/
|
|
224
|
+
async saveManyEvents(params) {
|
|
225
|
+
const bulkWriteOps = []; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
226
|
+
if (Array.isArray(params)) {
|
|
227
|
+
params.forEach((p) => {
|
|
228
|
+
const upsert = p.upsert === true;
|
|
229
|
+
if (p.attributes.typeOf === factory_1.factory.eventType.ScreeningEvent) {
|
|
230
|
+
// 上書き禁止属性を除外(2022-08-24~)
|
|
231
|
+
const { identifier, project, typeOf, remainingAttendeeCapacity, ...updateFields } = p.attributes; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
232
|
+
bulkWriteOps.push({
|
|
233
|
+
updateOne: {
|
|
234
|
+
filter: {
|
|
235
|
+
_id: p.id,
|
|
236
|
+
typeOf: p.attributes.typeOf
|
|
237
|
+
},
|
|
238
|
+
update: {
|
|
239
|
+
$setOnInsert: {
|
|
240
|
+
typeOf: p.attributes.typeOf,
|
|
241
|
+
project: p.attributes.project,
|
|
242
|
+
...(typeof p.attributes.identifier === 'string')
|
|
243
|
+
? { identifier: p.attributes.identifier } : undefined,
|
|
244
|
+
...(typeof p.attributes.remainingAttendeeCapacity === 'number')
|
|
245
|
+
? { remainingAttendeeCapacity: p.attributes.remainingAttendeeCapacity }
|
|
246
|
+
: undefined
|
|
247
|
+
},
|
|
248
|
+
$set: updateFields,
|
|
249
|
+
// $unsetに対応(2022-08-31~)
|
|
250
|
+
...(p.$unset !== undefined) ? { $unset: p.$unset } : undefined
|
|
251
|
+
},
|
|
252
|
+
upsert
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
else if (p.attributes.typeOf === factory_1.factory.eventType.ScreeningEventSeries) {
|
|
257
|
+
throw new factory_1.factory.errors.Internal('typeOf: ScreeningEventSeries discontinued');
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (bulkWriteOps.length > 0) {
|
|
262
|
+
await this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* イベントをキャンセルする
|
|
267
|
+
*/
|
|
268
|
+
async cancelEvent(params) {
|
|
269
|
+
return this.eventModel.updateOne({
|
|
270
|
+
_id: { $eq: params.id },
|
|
271
|
+
'project.id': { $eq: params.project.id }
|
|
272
|
+
}, { $set: { eventStatus: factory_1.factory.eventStatusType.EventCancelled } }, {
|
|
273
|
+
// includeResultMetadata: true
|
|
274
|
+
})
|
|
275
|
+
.exec();
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* 興行イベントのsuperEventを最新の情報に同期する
|
|
279
|
+
*/
|
|
280
|
+
async syncScreeningEventSeries2screeningEvents(params) {
|
|
281
|
+
const superEvent = EventFactory.minimizeSuperEvent({ superEventFromDB: params.superEventFromDB });
|
|
282
|
+
await this.eventModel.updateMany({
|
|
283
|
+
typeOf: { $eq: factory_1.factory.eventType.ScreeningEvent },
|
|
284
|
+
'project.id': { $eq: params.project.id },
|
|
285
|
+
'superEvent.id': { $exists: true, $eq: params.superEventFromDB.id },
|
|
286
|
+
startDate: { $gte: params.startDate.$gte }
|
|
287
|
+
}, {
|
|
288
|
+
$set: {
|
|
289
|
+
superEvent
|
|
290
|
+
}
|
|
291
|
+
})
|
|
292
|
+
.exec();
|
|
293
|
+
}
|
|
294
|
+
async deleteEventById(params) {
|
|
295
|
+
await this.eventModel.findOneAndDelete({
|
|
296
|
+
_id: params.id,
|
|
297
|
+
'project.id': { $eq: params.project.id }
|
|
298
|
+
})
|
|
299
|
+
.exec();
|
|
300
|
+
}
|
|
301
|
+
async deleteManyEventByOrganizerId(params) {
|
|
302
|
+
return this.eventModel.deleteMany({
|
|
303
|
+
'project.id': { $eq: params.project.id },
|
|
304
|
+
'organizer.id': { $exists: true, $eq: params.organizer.id }
|
|
305
|
+
})
|
|
306
|
+
.exec();
|
|
307
|
+
}
|
|
308
|
+
async deleteManyEventsByScreeningRoom(params) {
|
|
309
|
+
return this.eventModel.deleteMany({
|
|
310
|
+
'project.id': { $eq: params.project.id },
|
|
311
|
+
'location.branchCode': { $exists: true, $eq: params.location.branchCode },
|
|
312
|
+
'superEvent.location.id': { $exists: true, $eq: params.location.containedInPlace.id }
|
|
313
|
+
})
|
|
314
|
+
.exec();
|
|
315
|
+
}
|
|
316
|
+
async deleteManyBySuperEventId(params) {
|
|
317
|
+
return this.eventModel.deleteMany({
|
|
318
|
+
'project.id': { $eq: params.project.id },
|
|
319
|
+
'superEvent.id': { $exists: true, $eq: params.superEvent.id }
|
|
320
|
+
})
|
|
321
|
+
.exec();
|
|
322
|
+
}
|
|
323
|
+
async deleteManyBySuperEventLocationId(params) {
|
|
324
|
+
return this.eventModel.deleteMany({
|
|
325
|
+
'project.id': { $eq: params.project.id },
|
|
326
|
+
'superEvent.location.id': { $exists: true, $eq: params.superEvent.location.id }
|
|
327
|
+
})
|
|
328
|
+
.exec();
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 興行(プロダクト)から削除する
|
|
332
|
+
*/
|
|
333
|
+
async deleteManyEventsByItemOfferedId(params) {
|
|
334
|
+
return this.eventModel.deleteMany({
|
|
335
|
+
'project.id': { $eq: params.project.id },
|
|
336
|
+
'offers.itemOffered.id': { $exists: true, $in: params.offers.itemOffered.id.$in }
|
|
337
|
+
})
|
|
338
|
+
.exec();
|
|
339
|
+
}
|
|
340
|
+
async deleteManyEventsEndedByProject(params) {
|
|
341
|
+
return this.eventModel.deleteMany({
|
|
342
|
+
typeOf: { $in: params.typeOf.$in },
|
|
343
|
+
'project.id': { $eq: params.project.id },
|
|
344
|
+
endDate: { $lte: params.endDate.$lte }
|
|
345
|
+
})
|
|
346
|
+
.exec();
|
|
347
|
+
}
|
|
348
|
+
async deleteManyEventsEnded(params) {
|
|
349
|
+
return this.eventModel.deleteMany({
|
|
350
|
+
typeOf: { $eq: params.typeOf.$eq },
|
|
351
|
+
endDate: { $lte: params.endDate.$lte }
|
|
352
|
+
})
|
|
353
|
+
.exec();
|
|
354
|
+
}
|
|
355
|
+
async deleteByProject(params) {
|
|
356
|
+
await this.eventModel.deleteMany({
|
|
357
|
+
'project.id': { $eq: params.project.id }
|
|
358
|
+
})
|
|
359
|
+
.exec();
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* 集計属性を更新する
|
|
363
|
+
*/
|
|
364
|
+
async updateAggregationById(params, update) {
|
|
365
|
+
const doc = await this.eventModel.findOneAndUpdate({ _id: { $eq: params.id } }, update, {
|
|
366
|
+
new: false,
|
|
367
|
+
projection: { _id: 1 }
|
|
368
|
+
})
|
|
369
|
+
.lean()
|
|
370
|
+
.exec();
|
|
371
|
+
if (doc === null) {
|
|
372
|
+
throw new factory_1.factory.errors.NotFound(this.eventModel.modelName);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
async bulkWrite(bulkWriteOps) {
|
|
376
|
+
return this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
377
|
+
}
|
|
378
|
+
getCursor(conditions, projection) {
|
|
379
|
+
return this.eventModel.find(conditions, projection)
|
|
380
|
+
.sort({ startDate: factory_1.factory.sortType.Descending })
|
|
381
|
+
.cursor();
|
|
382
|
+
}
|
|
383
|
+
async unsetUnnecessaryFields(params) {
|
|
384
|
+
return this.eventModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
385
|
+
.exec();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
exports.AdminEventRepo = AdminEventRepo;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
interface IAggregationByStatus {
|
|
4
|
+
eventCount: number;
|
|
5
|
+
reservationCount: number;
|
|
6
|
+
avgOfferCount: number;
|
|
7
|
+
maximumAttendeeCapacity: number;
|
|
8
|
+
remainingAttendeeCapacity: number;
|
|
9
|
+
avgRemainingCapacityRate: number;
|
|
10
|
+
maxRemainingCapacityRate: number;
|
|
11
|
+
minRemainingCapacityRate: number;
|
|
12
|
+
percentilesRemainingCapacityRate: {
|
|
13
|
+
name: string;
|
|
14
|
+
value: number;
|
|
15
|
+
}[];
|
|
16
|
+
}
|
|
17
|
+
interface IStatus {
|
|
18
|
+
status: factory.eventStatusType;
|
|
19
|
+
aggregation: IAggregationByStatus;
|
|
20
|
+
}
|
|
21
|
+
interface IAggregateEvent {
|
|
22
|
+
statuses: IStatus[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* イベント集計リポジトリ
|
|
26
|
+
*/
|
|
27
|
+
export declare class AggregateEventRepo {
|
|
28
|
+
private readonly eventModel;
|
|
29
|
+
constructor(connection: Connection);
|
|
30
|
+
aggregateEvent(params: {
|
|
31
|
+
project?: {
|
|
32
|
+
id?: {
|
|
33
|
+
$ne?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
startFrom: Date;
|
|
37
|
+
startThrough: Date;
|
|
38
|
+
typeOf: factory.eventType.ScreeningEvent;
|
|
39
|
+
}): Promise<IAggregateEvent>;
|
|
40
|
+
private agggregateByStatus;
|
|
41
|
+
}
|
|
42
|
+
export {};
|