@chevre/domain 21.27.0-alpha.14 → 21.27.0-alpha.16
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/aggregation/aggregateEventReservation.ts +1 -0
- package/example/src/chevre/aggregation/aggregateOffersOnEvent.ts +43 -1
- package/lib/chevre/repo/aggregateReservation.d.ts +70 -0
- package/lib/chevre/repo/aggregateReservation.js +136 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +85 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/aggregation/event/aggregateOffers.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateOffers.js +12 -0
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +12 -0
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +11 -1
- package/lib/chevre/service/offer/onEventChanged.js +6 -2
- package/lib/chevre/service/task/aggregateOffers.js +2 -0
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -0
- package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +2 -0
- package/package.json +1 -1
|
@@ -21,6 +21,7 @@ async function main() {
|
|
|
21
21
|
await (await chevre.service.aggregation.createService()).event.aggregateScreeningEvent({
|
|
22
22
|
id: String(process.env.EVENT_ID)
|
|
23
23
|
})({
|
|
24
|
+
aggregateReservation: await chevre.repository.AggregateReservation.createInstance(mongoose.connection),
|
|
24
25
|
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
25
26
|
stockHolder: await chevre.repository.StockHolder.createInstance(client, mongoose.connection),
|
|
26
27
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
@@ -4,6 +4,9 @@ import * as redis from 'redis';
|
|
|
4
4
|
|
|
5
5
|
import { chevre } from '../../../../lib/index';
|
|
6
6
|
|
|
7
|
+
const project = { id: <string>process.env.PROJECT_ID };
|
|
8
|
+
const EVENT_ID = String(process.env.EVENT_ID);
|
|
9
|
+
|
|
7
10
|
// tslint:disable-next-line:max-func-body-length
|
|
8
11
|
async function main() {
|
|
9
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
@@ -16,10 +19,26 @@ async function main() {
|
|
|
16
19
|
});
|
|
17
20
|
await client.connect();
|
|
18
21
|
|
|
22
|
+
const aggregateReservationRepo = await chevre.repository.AggregateReservation.createInstance(mongoose.connection);
|
|
23
|
+
let aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
|
|
24
|
+
{
|
|
25
|
+
limit: 100,
|
|
26
|
+
page: 1,
|
|
27
|
+
project: { id: { $eq: project.id } },
|
|
28
|
+
reservationFor: {
|
|
29
|
+
id: { $eq: EVENT_ID },
|
|
30
|
+
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
['aggregateEntranceGate', 'aggregateReservation', 'aggregateOffer']
|
|
34
|
+
);
|
|
35
|
+
console.log('aggregateReservations:', aggregateReservations);
|
|
36
|
+
|
|
19
37
|
await (await chevre.service.aggregation.createService()).event.aggregateOffers({
|
|
20
|
-
id:
|
|
38
|
+
id: EVENT_ID,
|
|
21
39
|
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
22
40
|
})({
|
|
41
|
+
aggregateReservation: aggregateReservationRepo,
|
|
23
42
|
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
24
43
|
stockHolder: await chevre.repository.StockHolder.createInstance(client, mongoose.connection),
|
|
25
44
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
@@ -31,6 +50,29 @@ async function main() {
|
|
|
31
50
|
task: await chevre.repository.Task.createInstance(mongoose.connection)
|
|
32
51
|
});
|
|
33
52
|
console.log('aggregateReserveAction processed.');
|
|
53
|
+
|
|
54
|
+
aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
|
|
55
|
+
{
|
|
56
|
+
limit: 1,
|
|
57
|
+
page: 1,
|
|
58
|
+
sort: { 'reservationFor.startDate': 1 },
|
|
59
|
+
project: { id: { $eq: project.id } },
|
|
60
|
+
reservationFor: {
|
|
61
|
+
id: {
|
|
62
|
+
$eq: EVENT_ID,
|
|
63
|
+
$in: [EVENT_ID]
|
|
64
|
+
},
|
|
65
|
+
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
66
|
+
// startFrom: moment()
|
|
67
|
+
// .toDate(),
|
|
68
|
+
// startThrough: moment()
|
|
69
|
+
// .add(1, 'minutes')
|
|
70
|
+
// .toDate()
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
[]
|
|
74
|
+
);
|
|
75
|
+
console.log('aggregateReservations:', aggregateReservations);
|
|
34
76
|
}
|
|
35
77
|
|
|
36
78
|
main()
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Connection, PipelineStage } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
type IMatchStage = PipelineStage.Match;
|
|
4
|
+
export interface IAggregateReservation {
|
|
5
|
+
project: {
|
|
6
|
+
id: string;
|
|
7
|
+
typeOf: factory.organizationType.Project;
|
|
8
|
+
};
|
|
9
|
+
typeOf: 'AggregateReservation';
|
|
10
|
+
reservationFor: {
|
|
11
|
+
id: string;
|
|
12
|
+
typeOf: factory.eventType;
|
|
13
|
+
startDate: Date;
|
|
14
|
+
};
|
|
15
|
+
aggregateEntranceGate?: factory.event.screeningEvent.IAggregateEntranceGate;
|
|
16
|
+
aggregateReservation?: factory.event.screeningEvent.IAggregateReservation;
|
|
17
|
+
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
18
|
+
}
|
|
19
|
+
export interface IUpdateAggregateReservationParams {
|
|
20
|
+
$set: {
|
|
21
|
+
aggregateReservation?: factory.event.screeningEvent.IAggregateReservation;
|
|
22
|
+
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
23
|
+
aggregateEntranceGate?: factory.event.screeningEvent.IAggregateEntranceGate;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
type ISearchWithReservationForIdResult = Pick<IAggregateReservation, 'aggregateEntranceGate' | 'aggregateOffer' | 'aggregateReservation'> & {
|
|
27
|
+
/**
|
|
28
|
+
* イベントID
|
|
29
|
+
*/
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
|
32
|
+
export interface ISortOrder {
|
|
33
|
+
'reservationFor.startDate'?: factory.sortType;
|
|
34
|
+
}
|
|
35
|
+
export interface ISearchConditions {
|
|
36
|
+
limit?: number;
|
|
37
|
+
page?: number;
|
|
38
|
+
sort?: ISortOrder;
|
|
39
|
+
project?: {
|
|
40
|
+
id?: {
|
|
41
|
+
$eq?: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
reservationFor?: {
|
|
45
|
+
id?: {
|
|
46
|
+
$eq?: string;
|
|
47
|
+
$in?: string[];
|
|
48
|
+
};
|
|
49
|
+
typeOf?: factory.eventType;
|
|
50
|
+
startFrom?: Date;
|
|
51
|
+
startThrough?: Date;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 予約集計リポジトリ
|
|
56
|
+
*/
|
|
57
|
+
export declare class MongoRepository {
|
|
58
|
+
private readonly aggregateReservationModel;
|
|
59
|
+
constructor(connection: Connection);
|
|
60
|
+
static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): IMatchStage[];
|
|
61
|
+
/**
|
|
62
|
+
* 予約集計を検索する
|
|
63
|
+
*/
|
|
64
|
+
searchWithReservationForId(params: ISearchConditions, inclusion: ('aggregateEntranceGate' | 'aggregateOffer' | 'aggregateReservation')[]): Promise<ISearchWithReservationForIdResult[]>;
|
|
65
|
+
/**
|
|
66
|
+
* 予約集計を保管する
|
|
67
|
+
*/
|
|
68
|
+
save(filter: Pick<IAggregateReservation, 'project' | 'reservationFor'>, update: IUpdateAggregateReservationParams): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MongoRepository = void 0;
|
|
13
|
+
const factory = require("../factory");
|
|
14
|
+
const settings_1 = require("../settings");
|
|
15
|
+
const aggregateReservation_1 = require("./mongoose/schemas/aggregateReservation");
|
|
16
|
+
/**
|
|
17
|
+
* 予約集計リポジトリ
|
|
18
|
+
*/
|
|
19
|
+
class MongoRepository {
|
|
20
|
+
constructor(connection) {
|
|
21
|
+
this.aggregateReservationModel = connection.model(aggregateReservation_1.modelName, (0, aggregateReservation_1.createSchema)());
|
|
22
|
+
}
|
|
23
|
+
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
25
|
+
const matchStages = [];
|
|
26
|
+
const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
27
|
+
if (typeof projectIdEq === 'string') {
|
|
28
|
+
matchStages.push({
|
|
29
|
+
$match: { 'project.id': { $eq: projectIdEq } }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const typeOfEq = (_c = conditions.reservationFor) === null || _c === void 0 ? void 0 : _c.typeOf;
|
|
33
|
+
if (typeof typeOfEq === 'string') {
|
|
34
|
+
matchStages.push({
|
|
35
|
+
$match: { 'reservationFor.typeOf': { $eq: typeOfEq } }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const idEq = (_e = (_d = conditions.reservationFor) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
39
|
+
if (typeof idEq === 'string') {
|
|
40
|
+
matchStages.push({
|
|
41
|
+
$match: { 'reservationFor.id': { $eq: idEq } }
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const idIn = (_g = (_f = conditions.reservationFor) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$in;
|
|
45
|
+
if (Array.isArray(idIn)) {
|
|
46
|
+
matchStages.push({
|
|
47
|
+
$match: { 'reservationFor.id': { $in: idIn } }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const reservationForStartDateGte = (_h = conditions.reservationFor) === null || _h === void 0 ? void 0 : _h.startFrom;
|
|
51
|
+
if (reservationForStartDateGte instanceof Date) {
|
|
52
|
+
matchStages.push({
|
|
53
|
+
$match: { 'reservationFor.startDate': { $gte: reservationForStartDateGte } }
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const reservationForStartDateLte = (_j = conditions.reservationFor) === null || _j === void 0 ? void 0 : _j.startThrough;
|
|
57
|
+
if (reservationForStartDateLte instanceof Date) {
|
|
58
|
+
matchStages.push({
|
|
59
|
+
$match: { 'reservationFor.startDate': { $lte: reservationForStartDateLte } }
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return matchStages;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 予約集計を検索する
|
|
66
|
+
*/
|
|
67
|
+
searchWithReservationForId(params, inclusion) {
|
|
68
|
+
var _a;
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const matchStages = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
71
|
+
let projection = {
|
|
72
|
+
_id: 0,
|
|
73
|
+
id: '$reservationFor.id'
|
|
74
|
+
};
|
|
75
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
76
|
+
inclusion.forEach((field) => {
|
|
77
|
+
projection[field] = 1;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
projection = {
|
|
82
|
+
_id: 0,
|
|
83
|
+
id: '$reservationFor.id',
|
|
84
|
+
aggregateEntranceGate: 1,
|
|
85
|
+
aggregateOffer: 1,
|
|
86
|
+
aggregateReservation: 1
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const sortByStartDate = (_a = params.sort) === null || _a === void 0 ? void 0 : _a['reservationFor.startDate'];
|
|
90
|
+
const aggregate = this.aggregateReservationModel.aggregate([
|
|
91
|
+
...matchStages,
|
|
92
|
+
...(typeof sortByStartDate === 'number')
|
|
93
|
+
? [{ $sort: { 'reservationFor.startDate': sortByStartDate } }]
|
|
94
|
+
: [],
|
|
95
|
+
{ $project: projection }
|
|
96
|
+
]);
|
|
97
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
98
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
99
|
+
aggregate.limit(params.limit * page)
|
|
100
|
+
.skip(params.limit * (page - 1));
|
|
101
|
+
}
|
|
102
|
+
return aggregate
|
|
103
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
104
|
+
.exec();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 予約集計を保管する
|
|
109
|
+
*/
|
|
110
|
+
save(filter, update) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const { $set } = update;
|
|
113
|
+
const setOnInsert = {
|
|
114
|
+
project: { id: filter.project.id, typeOf: factory.organizationType.Project },
|
|
115
|
+
typeOf: 'AggregateReservation',
|
|
116
|
+
reservationFor: filter.reservationFor
|
|
117
|
+
};
|
|
118
|
+
const doc = yield this.aggregateReservationModel.findOneAndUpdate({
|
|
119
|
+
'project.id': { $eq: filter.project.id },
|
|
120
|
+
'reservationFor.id': { $eq: filter.reservationFor.id }
|
|
121
|
+
}, {
|
|
122
|
+
$set: Object.assign({ updatedAt: new Date() }, $set),
|
|
123
|
+
$setOnInsert: setOnInsert
|
|
124
|
+
}, {
|
|
125
|
+
new: true,
|
|
126
|
+
upsert: true,
|
|
127
|
+
projection: { _id: 1 }
|
|
128
|
+
})
|
|
129
|
+
.exec();
|
|
130
|
+
if (doc === null) {
|
|
131
|
+
throw new factory.errors.NotFound(this.aggregateReservationModel.modelName);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
|
|
2
|
+
declare const modelName = "AggregateReservation";
|
|
3
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
4
|
+
declare function createSchema(): Schema;
|
|
5
|
+
export { modelName, indexes, createSchema };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSchema = exports.indexes = exports.modelName = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
7
|
+
const modelName = 'AggregateReservation';
|
|
8
|
+
exports.modelName = modelName;
|
|
9
|
+
const schemaDefinition = {
|
|
10
|
+
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
11
|
+
typeOf: { type: String, required: true },
|
|
12
|
+
reservationFor: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
13
|
+
aggregateEntranceGate: mongoose_1.SchemaTypes.Mixed,
|
|
14
|
+
aggregateReservation: mongoose_1.SchemaTypes.Mixed,
|
|
15
|
+
aggregateOffer: mongoose_1.SchemaTypes.Mixed
|
|
16
|
+
};
|
|
17
|
+
const schemaOptions = {
|
|
18
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
19
|
+
autoCreate: false,
|
|
20
|
+
collection: 'aggregateReservations',
|
|
21
|
+
id: true,
|
|
22
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
23
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
24
|
+
strict: true,
|
|
25
|
+
strictQuery: false,
|
|
26
|
+
timestamps: {
|
|
27
|
+
createdAt: 'createdAt',
|
|
28
|
+
updatedAt: 'updatedAt'
|
|
29
|
+
},
|
|
30
|
+
toJSON: {
|
|
31
|
+
getters: false,
|
|
32
|
+
virtuals: false,
|
|
33
|
+
minimize: false,
|
|
34
|
+
versionKey: false
|
|
35
|
+
},
|
|
36
|
+
toObject: {
|
|
37
|
+
getters: false,
|
|
38
|
+
virtuals: true,
|
|
39
|
+
minimize: false,
|
|
40
|
+
versionKey: false
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const indexes = [
|
|
44
|
+
[
|
|
45
|
+
{ createdAt: 1 },
|
|
46
|
+
{ name: 'searchByCreatedAt' }
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
{ updatedAt: 1 },
|
|
50
|
+
{ name: 'searchByUpdatedAt' }
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
{ 'reservationFor.startDate': 1 },
|
|
54
|
+
{ name: 'searchByReservationForStartDate' }
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
{ 'project.id': 1, 'reservationFor.startDate': 1 },
|
|
58
|
+
{ name: 'searchByProjectId' }
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
{ 'reservationFor.id': 1, 'reservationFor.startDate': 1 },
|
|
62
|
+
{ name: 'searchByReservationForId' }
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
{ 'reservationFor.typeOf': 1, 'reservationFor.startDate': 1 },
|
|
66
|
+
{ name: 'searchByReservationForTypeOf' }
|
|
67
|
+
]
|
|
68
|
+
];
|
|
69
|
+
exports.indexes = indexes;
|
|
70
|
+
/**
|
|
71
|
+
* 予約集計スキーマ
|
|
72
|
+
*/
|
|
73
|
+
let schema;
|
|
74
|
+
function createSchema() {
|
|
75
|
+
if (schema === undefined) {
|
|
76
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
77
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
78
|
+
indexes.forEach((indexParams) => {
|
|
79
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return schema;
|
|
84
|
+
}
|
|
85
|
+
exports.createSchema = createSchema;
|
|
@@ -9,6 +9,7 @@ import type { MongoRepository as AccountTransactionRepo } from './repo/accountTr
|
|
|
9
9
|
import type { MongoRepository as ActionRepo } from './repo/action';
|
|
10
10
|
import type { MongoRepository as AdditionalPropertyRepo } from './repo/additionalProperty';
|
|
11
11
|
import type { MongoRepository as AggregateOfferRepo } from './repo/aggregateOffer';
|
|
12
|
+
import type { MongoRepository as AggregateReservationRepo } from './repo/aggregateReservation';
|
|
12
13
|
import type { MongoRepository as AggregationRepo } from './repo/aggregation';
|
|
13
14
|
import type { MongoRepository as AssetTransactionRepo } from './repo/assetTransaction';
|
|
14
15
|
import type { MongoRepository as CategoryCodeRepo } from './repo/categoryCode';
|
|
@@ -87,6 +88,10 @@ export type AggregateOffer = AggregateOfferRepo;
|
|
|
87
88
|
export declare namespace AggregateOffer {
|
|
88
89
|
function createInstance(...params: ConstructorParameters<typeof AggregateOfferRepo>): Promise<AggregateOfferRepo>;
|
|
89
90
|
}
|
|
91
|
+
export type AggregateReservation = AggregateReservationRepo;
|
|
92
|
+
export declare namespace AggregateReservation {
|
|
93
|
+
function createInstance(...params: ConstructorParameters<typeof AggregateReservationRepo>): Promise<AggregateReservationRepo>;
|
|
94
|
+
}
|
|
90
95
|
export type Aggregation = AggregationRepo;
|
|
91
96
|
export declare namespace Aggregation {
|
|
92
97
|
function createInstance(...params: ConstructorParameters<typeof AggregationRepo>): Promise<AggregationRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = void 0;
|
|
12
|
+
exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -115,6 +115,19 @@ var AggregateOffer;
|
|
|
115
115
|
}
|
|
116
116
|
AggregateOffer.createInstance = createInstance;
|
|
117
117
|
})(AggregateOffer = exports.AggregateOffer || (exports.AggregateOffer = {}));
|
|
118
|
+
var AggregateReservation;
|
|
119
|
+
(function (AggregateReservation) {
|
|
120
|
+
let repo;
|
|
121
|
+
function createInstance(...params) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
if (repo === undefined) {
|
|
124
|
+
repo = (yield Promise.resolve().then(() => require('./repo/aggregateReservation'))).MongoRepository;
|
|
125
|
+
}
|
|
126
|
+
return new repo(...params);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
AggregateReservation.createInstance = createInstance;
|
|
130
|
+
})(AggregateReservation = exports.AggregateReservation || (exports.AggregateReservation = {}));
|
|
118
131
|
var Aggregation;
|
|
119
132
|
(function (Aggregation) {
|
|
120
133
|
let repo;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MongoRepository as AggregateReservationRepo } from '../../../repo/aggregateReservation';
|
|
1
2
|
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
2
3
|
import type { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
3
4
|
import type { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
@@ -9,6 +10,7 @@ import type { StockHolderRepository as StockHolderRepo } from '../../../repo/sto
|
|
|
9
10
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
10
11
|
import * as factory from '../../../factory';
|
|
11
12
|
type IAggregateOffersOperation<T> = (repos: {
|
|
13
|
+
aggregateReservation: AggregateReservationRepo;
|
|
12
14
|
event: EventRepo;
|
|
13
15
|
stockHolder: StockHolderRepo;
|
|
14
16
|
offer: OfferRepo;
|
|
@@ -75,6 +75,18 @@ function aggregateOffersByEvent(params) {
|
|
|
75
75
|
// 保管
|
|
76
76
|
const saveResult = yield repos.event.updateAggregationById({ id: event.id }, update);
|
|
77
77
|
debug('aggregateOffersByEvent processd', saveResult);
|
|
78
|
+
// aggregateReservationsにも保管(2024-03-25~)
|
|
79
|
+
yield repos.aggregateReservation.save({
|
|
80
|
+
project: event.project,
|
|
81
|
+
reservationFor: {
|
|
82
|
+
id: event.id,
|
|
83
|
+
typeOf: event.typeOf,
|
|
84
|
+
startDate: moment(event.startDate)
|
|
85
|
+
.toDate()
|
|
86
|
+
}
|
|
87
|
+
}, {
|
|
88
|
+
$set: { aggregateOffer }
|
|
89
|
+
});
|
|
78
90
|
});
|
|
79
91
|
}
|
|
80
92
|
function reservedSeatsAvailable(params) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MongoRepository as AggregateReservationRepo } from '../../../repo/aggregateReservation';
|
|
1
2
|
import { IMinimizedIndividualEvent, MongoRepository as EventRepo } from '../../../repo/event';
|
|
2
3
|
import type { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
3
4
|
import type { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
@@ -9,6 +10,7 @@ import type { StockHolderRepository as StockHolderRepo } from '../../../repo/sto
|
|
|
9
10
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
10
11
|
import * as factory from '../../../factory';
|
|
11
12
|
export type IAggregateScreeningEventOperation<T> = (repos: {
|
|
13
|
+
aggregateReservation: AggregateReservationRepo;
|
|
12
14
|
event: EventRepo;
|
|
13
15
|
stockHolder: StockHolderRepo;
|
|
14
16
|
offer: OfferRepo;
|
|
@@ -122,6 +122,18 @@ function aggregateByEvent(params) {
|
|
|
122
122
|
debug('update:', update);
|
|
123
123
|
// 保管
|
|
124
124
|
yield repos.event.updateAggregationById({ id: event.id }, update);
|
|
125
|
+
// aggregateReservationsにも保管(2024-03-25~)
|
|
126
|
+
yield repos.aggregateReservation.save({
|
|
127
|
+
project: event.project,
|
|
128
|
+
reservationFor: {
|
|
129
|
+
id: event.id,
|
|
130
|
+
typeOf: event.typeOf,
|
|
131
|
+
startDate: moment(event.startDate)
|
|
132
|
+
.toDate()
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
$set: { aggregateReservation }
|
|
136
|
+
});
|
|
125
137
|
yield onAggregated({ event })({
|
|
126
138
|
task: repos.task
|
|
127
139
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
2
|
+
import type { MongoRepository as AggregateReservationRepo } from '../../../repo/aggregateReservation';
|
|
2
3
|
import type { MongoRepository as EventRepo } from '../../../repo/event';
|
|
3
4
|
import type { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
4
5
|
import type { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
@@ -6,6 +7,7 @@ import type { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
|
6
7
|
import type { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
7
8
|
export type IAggregateOperation<T> = (repos: {
|
|
8
9
|
action: ActionRepo;
|
|
10
|
+
aggregateReservation: AggregateReservationRepo;
|
|
9
11
|
event: EventRepo;
|
|
10
12
|
offer: OfferRepo;
|
|
11
13
|
offerCatalog: OfferCatalogRepo;
|
|
@@ -14,6 +14,7 @@ exports.aggregateUseActionsOnEvent = void 0;
|
|
|
14
14
|
* イベント入場集計サービス
|
|
15
15
|
*/
|
|
16
16
|
const createDebug = require("debug");
|
|
17
|
+
const moment = require("moment-timezone");
|
|
17
18
|
const factory = require("../../../factory");
|
|
18
19
|
const findEventOffers_1 = require("./findEventOffers");
|
|
19
20
|
const debug = createDebug('chevre-domain:service');
|
|
@@ -22,7 +23,6 @@ function aggregateUseActionsOnEvent(params) {
|
|
|
22
23
|
const now = new Date();
|
|
23
24
|
// 集計対象イベント検索
|
|
24
25
|
// イベント取得属性最適化(2023-01-23~)
|
|
25
|
-
// const event = await repos.event.findById<factory.eventType.ScreeningEvent>(params);
|
|
26
26
|
const event = yield repos.event.findMinimizedIndividualEventById(params);
|
|
27
27
|
// 入場ゲート検索
|
|
28
28
|
const entranceGates = yield findEntranceGates({ event })(repos);
|
|
@@ -46,6 +46,16 @@ function aggregateUseActionsOnEvent(params) {
|
|
|
46
46
|
debug('update:', update);
|
|
47
47
|
// 保管
|
|
48
48
|
yield repos.event.updateAggregationById({ id: event.id }, update);
|
|
49
|
+
// aggregateReservationsにも保管(2024-03-25~)
|
|
50
|
+
yield repos.aggregateReservation.save({
|
|
51
|
+
project: event.project,
|
|
52
|
+
reservationFor: {
|
|
53
|
+
id: event.id,
|
|
54
|
+
typeOf: event.typeOf,
|
|
55
|
+
startDate: moment(event.startDate)
|
|
56
|
+
.toDate()
|
|
57
|
+
}
|
|
58
|
+
}, { $set: { aggregateEntranceGate } });
|
|
49
59
|
});
|
|
50
60
|
}
|
|
51
61
|
exports.aggregateUseActionsOnEvent = aggregateUseActionsOnEvent;
|
|
@@ -170,10 +170,14 @@ function createInformTasks(params) {
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
else {
|
|
173
|
-
|
|
173
|
+
const screeningEventSeries4inform = yield repos.event.search({
|
|
174
174
|
id: { $in: params.ids },
|
|
175
175
|
typeOf: params.typeOf
|
|
176
|
-
}, [], []);
|
|
176
|
+
}, [], ['offers']);
|
|
177
|
+
// 最適化(2024-03-25~)
|
|
178
|
+
events4inform = screeningEventSeries4inform.map(({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus, endDate, startDate, additionalProperty, subtitleLanguage, dubLanguage, alternativeHeadline, description, duration, headline }) => {
|
|
179
|
+
return Object.assign(Object.assign(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 }, (endDate !== undefined) ? { endDate } : undefined), (startDate !== undefined) ? { startDate } : undefined), (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);
|
|
180
|
+
});
|
|
177
181
|
}
|
|
178
182
|
if (events4inform.length > 0) {
|
|
179
183
|
const taskRunsAt = new Date();
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
|
+
const aggregateReservation_1 = require("../../repo/aggregateReservation");
|
|
14
15
|
const event_1 = require("../../repo/event");
|
|
15
16
|
const offer_1 = require("../../repo/offer");
|
|
16
17
|
const offerCatalog_1 = require("../../repo/offerCatalog");
|
|
@@ -30,6 +31,7 @@ function call(data) {
|
|
|
30
31
|
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
31
32
|
}
|
|
32
33
|
yield (0, aggregateOffers_1.aggregateOffers)(data)({
|
|
34
|
+
aggregateReservation: new aggregateReservation_1.MongoRepository(settings.connection),
|
|
33
35
|
event: new event_1.MongoRepository(settings.connection),
|
|
34
36
|
stockHolder: new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection),
|
|
35
37
|
offer: new offer_1.MongoRepository(settings.connection),
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
|
+
const aggregateReservation_1 = require("../../repo/aggregateReservation");
|
|
14
15
|
const event_1 = require("../../repo/event");
|
|
15
16
|
const offer_1 = require("../../repo/offer");
|
|
16
17
|
const offerCatalog_1 = require("../../repo/offerCatalog");
|
|
@@ -30,6 +31,7 @@ function call(data) {
|
|
|
30
31
|
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
31
32
|
}
|
|
32
33
|
yield AggregationService.event.aggregateScreeningEvent(data)({
|
|
34
|
+
aggregateReservation: new aggregateReservation_1.MongoRepository(settings.connection),
|
|
33
35
|
event: new event_1.MongoRepository(settings.connection),
|
|
34
36
|
stockHolder: new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection),
|
|
35
37
|
offer: new offer_1.MongoRepository(settings.connection),
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
|
+
const aggregateReservation_1 = require("../../repo/aggregateReservation");
|
|
15
16
|
const event_1 = require("../../repo/event");
|
|
16
17
|
const offer_1 = require("../../repo/offer");
|
|
17
18
|
const offerCatalog_1 = require("../../repo/offerCatalog");
|
|
@@ -28,6 +29,7 @@ function call(data) {
|
|
|
28
29
|
}
|
|
29
30
|
yield AggregationService.event.aggregateUseActionsOnEvent(data)({
|
|
30
31
|
action: new action_1.MongoRepository(settings.connection),
|
|
32
|
+
aggregateReservation: new aggregateReservation_1.MongoRepository(settings.connection),
|
|
31
33
|
event: new event_1.MongoRepository(settings.connection),
|
|
32
34
|
offer: new offer_1.MongoRepository(settings.connection),
|
|
33
35
|
offerCatalog: new offerCatalog_1.MongoRepository(settings.connection),
|
package/package.json
CHANGED