@chevre/domain 20.1.0-alpha.26 → 20.1.0-alpha.28
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/migrateCreativeWorkAdditionalProperties.ts +4 -0
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +162 -0
- package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +63 -0
- package/lib/chevre/repo/mongoose/model/categoryCode.js +11 -2
- package/lib/chevre/repo/mongoose/model/offerCatalog.js +21 -2
- package/lib/chevre/repo/mongoose/model/ownershipInfo.js +3 -15
- package/lib/chevre/repo/mongoose/model/place.js +18 -0
- package/lib/chevre/repo/offerCatalog.js +10 -10
- package/lib/chevre/repo/place.js +39 -6
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +0 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateSellerMakesOfferTransactionDuration.ts +0 -71
|
@@ -42,6 +42,7 @@ async function main() {
|
|
|
42
42
|
|
|
43
43
|
const additionalPropertyNames: string[] = [];
|
|
44
44
|
const projectIds: string[] = [];
|
|
45
|
+
const unexpextedprojectIds: string[] = [];
|
|
45
46
|
|
|
46
47
|
let i = 0;
|
|
47
48
|
let updateCount = 0;
|
|
@@ -62,10 +63,12 @@ async function main() {
|
|
|
62
63
|
additionalPropertyNamesOnEvent.forEach((name) => {
|
|
63
64
|
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
64
65
|
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
66
|
+
unexpextedprojectIds.push(creativeWork.project.id);
|
|
65
67
|
}
|
|
66
68
|
// tslint:disable-next-line:no-magic-numbers
|
|
67
69
|
if (name.length < 5) {
|
|
68
70
|
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
71
|
+
unexpextedprojectIds.push(creativeWork.project.id);
|
|
69
72
|
}
|
|
70
73
|
});
|
|
71
74
|
|
|
@@ -101,6 +104,7 @@ async function main() {
|
|
|
101
104
|
console.log(updateCount, 'events updated');
|
|
102
105
|
console.log([...new Set(additionalPropertyNames)]);
|
|
103
106
|
console.log([...new Set(projectIds)]);
|
|
107
|
+
console.log([...new Set(unexpextedprojectIds)]);
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
main()
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
+
|
|
14
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = placeRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
20
|
+
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
21
|
+
// starDate: { $gte: new Date() }
|
|
22
|
+
// _id: { $eq: 'al6aff83w' }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
// _id: 1,
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('creativeWorks found');
|
|
29
|
+
|
|
30
|
+
const additionalPropertyNames: string[] = [];
|
|
31
|
+
const additionalPropertyNamesOnSections: string[] = [];
|
|
32
|
+
const additionalPropertyNamesOnSeats: string[] = [];
|
|
33
|
+
const projectIds: string[] = [];
|
|
34
|
+
const unexpextedprojectIds: string[] = [];
|
|
35
|
+
const projectIdsOnSections: string[] = [];
|
|
36
|
+
const unexpextedprojectIdsOnSections: string[] = [];
|
|
37
|
+
const projectIdsOnSeats: string[] = [];
|
|
38
|
+
const unexpextedprojectIdsOnSeats: string[] = [];
|
|
39
|
+
|
|
40
|
+
let i = 0;
|
|
41
|
+
let updateCount = 0;
|
|
42
|
+
// tslint:disable-next-line:max-func-body-length
|
|
43
|
+
await cursor.eachAsync(async (doc) => {
|
|
44
|
+
i += 1;
|
|
45
|
+
const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
|
|
46
|
+
|
|
47
|
+
if (Array.isArray(movieTheater.containsPlace)) {
|
|
48
|
+
movieTheater.containsPlace.forEach((screeningRoom) => {
|
|
49
|
+
const additionalPropertyNamesOnResource = screeningRoom.additionalProperty?.map((p) => p.name);
|
|
50
|
+
console.log(
|
|
51
|
+
(Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
|
|
52
|
+
'additionalPropertyNamesOnResource found',
|
|
53
|
+
movieTheater.project.id,
|
|
54
|
+
movieTheater.id
|
|
55
|
+
);
|
|
56
|
+
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
57
|
+
console.log(
|
|
58
|
+
additionalPropertyNamesOnResource.length,
|
|
59
|
+
'additionalPropertyNamesOnResource found',
|
|
60
|
+
movieTheater.project.id,
|
|
61
|
+
movieTheater.id
|
|
62
|
+
);
|
|
63
|
+
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
64
|
+
projectIds.push(movieTheater.project.id);
|
|
65
|
+
additionalPropertyNamesOnResource.forEach((name) => {
|
|
66
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
67
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
68
|
+
unexpextedprojectIds.push(movieTheater.project.id);
|
|
69
|
+
}
|
|
70
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
71
|
+
if (name.length < 5) {
|
|
72
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
73
|
+
unexpextedprojectIds.push(movieTheater.project.id);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (Array.isArray(screeningRoom.containsPlace)) {
|
|
79
|
+
screeningRoom.containsPlace.forEach((section) => {
|
|
80
|
+
const additionalPropertyNamesOnSection = section.additionalProperty?.map((p) => p.name);
|
|
81
|
+
console.log(
|
|
82
|
+
(Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
|
|
83
|
+
'additionalPropertyNamesOnSection found',
|
|
84
|
+
movieTheater.project.id,
|
|
85
|
+
movieTheater.id
|
|
86
|
+
);
|
|
87
|
+
if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
|
|
88
|
+
console.log(
|
|
89
|
+
additionalPropertyNamesOnSection.length,
|
|
90
|
+
'additionalPropertyNamesOnSection found',
|
|
91
|
+
movieTheater.project.id,
|
|
92
|
+
movieTheater.id
|
|
93
|
+
);
|
|
94
|
+
additionalPropertyNamesOnSections.push(...additionalPropertyNamesOnSection);
|
|
95
|
+
projectIdsOnSections.push(movieTheater.project.id);
|
|
96
|
+
additionalPropertyNamesOnSection.forEach((name) => {
|
|
97
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
98
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
99
|
+
unexpextedprojectIdsOnSections.push(movieTheater.project.id);
|
|
100
|
+
}
|
|
101
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
102
|
+
if (name.length < 5) {
|
|
103
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
104
|
+
unexpextedprojectIdsOnSections.push(movieTheater.project.id);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (Array.isArray(section.containsPlace)) {
|
|
110
|
+
section.containsPlace.forEach((seat) => {
|
|
111
|
+
const additionalPropertyNamesOnSeat = seat.additionalProperty?.map((p) => p.name);
|
|
112
|
+
console.log(
|
|
113
|
+
(Array.isArray(additionalPropertyNamesOnSeat)) ? additionalPropertyNamesOnSeat.length : 0,
|
|
114
|
+
'additionalPropertyNamesOnSeat found',
|
|
115
|
+
movieTheater.project.id,
|
|
116
|
+
movieTheater.id
|
|
117
|
+
);
|
|
118
|
+
if (Array.isArray(additionalPropertyNamesOnSeat) && additionalPropertyNamesOnSeat.length > 0) {
|
|
119
|
+
console.log(
|
|
120
|
+
additionalPropertyNamesOnSeat.length,
|
|
121
|
+
'additionalPropertyNamesOnSeat found',
|
|
122
|
+
movieTheater.project.id,
|
|
123
|
+
movieTheater.id
|
|
124
|
+
);
|
|
125
|
+
additionalPropertyNamesOnSeats.push(...additionalPropertyNamesOnSeat);
|
|
126
|
+
projectIdsOnSeats.push(movieTheater.project.id);
|
|
127
|
+
additionalPropertyNamesOnSeat.forEach((name) => {
|
|
128
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
129
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
130
|
+
unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
|
|
131
|
+
}
|
|
132
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
133
|
+
if (name.length < 5) {
|
|
134
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
135
|
+
unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
console.log(i, 'places checked');
|
|
148
|
+
console.log(updateCount, 'places updated');
|
|
149
|
+
console.log([...new Set(additionalPropertyNames)], 'screeningRooms');
|
|
150
|
+
console.log([...new Set(projectIds)], 'screeningRooms');
|
|
151
|
+
console.log([...new Set(unexpextedprojectIds)], 'screeningRooms');
|
|
152
|
+
console.log([...new Set(additionalPropertyNamesOnSections)], 'sections');
|
|
153
|
+
console.log([...new Set(projectIdsOnSections)], 'sections');
|
|
154
|
+
console.log([...new Set(unexpextedprojectIdsOnSections)], 'sections');
|
|
155
|
+
console.log([...new Set(additionalPropertyNamesOnSeats)], 'seats');
|
|
156
|
+
console.log([...new Set(projectIdsOnSeats)], 'seats');
|
|
157
|
+
console.log([...new Set(unexpextedprojectIdsOnSeats)], 'seats');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
main()
|
|
161
|
+
.then()
|
|
162
|
+
.catch(console.error);
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
const DELETING_PROPERTY_NAME: string = 'COA_ENDPOINT';
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
11
|
+
|
|
12
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = eventRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
'project.id': { $eq: project.id },
|
|
17
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries }
|
|
18
|
+
// typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
// _id: 1,
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
console.log('events found');
|
|
25
|
+
|
|
26
|
+
let i = 0;
|
|
27
|
+
let updateCount = 0;
|
|
28
|
+
await cursor.eachAsync(async (doc) => {
|
|
29
|
+
i += 1;
|
|
30
|
+
const event: chevre.factory.event.IEvent<chevre.factory.eventType> = doc.toObject();
|
|
31
|
+
|
|
32
|
+
const coaEndpointPropert = event.additionalProperty?.find((p) => p.name === DELETING_PROPERTY_NAME);
|
|
33
|
+
|
|
34
|
+
if (coaEndpointPropert !== undefined) {
|
|
35
|
+
const newAdditionalProperty: chevre.factory.propertyValue.IPropertyValue<string>[] =
|
|
36
|
+
(Array.isArray(event.additionalProperty))
|
|
37
|
+
? event.additionalProperty.filter((p) => {
|
|
38
|
+
return p.name !== DELETING_PROPERTY_NAME;
|
|
39
|
+
})
|
|
40
|
+
: [];
|
|
41
|
+
console.log(
|
|
42
|
+
'updating event...', event.project.id, event.id, event.startDate, coaEndpointPropert.value, newAdditionalProperty, i);
|
|
43
|
+
await eventRepo.updatePartiallyById({
|
|
44
|
+
id: event.id,
|
|
45
|
+
attributes: <any>{
|
|
46
|
+
typeOf: event.typeOf,
|
|
47
|
+
additionalProperty: newAdditionalProperty
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
updateCount += 1;
|
|
51
|
+
console.log('event updated', event.project.id, event.id, event.startDate, i);
|
|
52
|
+
} else {
|
|
53
|
+
console.log('no property...', event.project.id, event.id, event.startDate, i);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
console.log(i, 'events checked');
|
|
58
|
+
console.log(updateCount, 'events updated');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
main()
|
|
62
|
+
.then()
|
|
63
|
+
.catch(console.error);
|
|
@@ -14,13 +14,22 @@ const schema = new mongoose.Schema({
|
|
|
14
14
|
type: String,
|
|
15
15
|
required: true
|
|
16
16
|
},
|
|
17
|
-
additionalProperty: [mongoose.SchemaTypes.Mixed]
|
|
17
|
+
additionalProperty: [mongoose.SchemaTypes.Mixed],
|
|
18
|
+
color: String,
|
|
19
|
+
image: String,
|
|
20
|
+
codeValue: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
inCodeSet: mongoose.SchemaTypes.Mixed,
|
|
25
|
+
name: mongoose.SchemaTypes.Mixed,
|
|
26
|
+
paymentMethod: mongoose.SchemaTypes.Mixed
|
|
18
27
|
}, {
|
|
19
28
|
collection: 'categoryCodes',
|
|
20
29
|
id: true,
|
|
21
30
|
read: 'primaryPreferred',
|
|
22
31
|
writeConcern: writeConcern,
|
|
23
|
-
strict:
|
|
32
|
+
strict: true,
|
|
24
33
|
useNestedStrict: true,
|
|
25
34
|
timestamps: {
|
|
26
35
|
createdAt: 'createdAt',
|
|
@@ -11,13 +11,26 @@ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
|
|
|
11
11
|
const schema = new mongoose.Schema({
|
|
12
12
|
project: mongoose.SchemaTypes.Mixed,
|
|
13
13
|
_id: String,
|
|
14
|
-
identifier:
|
|
14
|
+
identifier: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
name: mongoose.SchemaTypes.Mixed,
|
|
19
|
+
description: mongoose.SchemaTypes.Mixed,
|
|
20
|
+
alternateName: mongoose.SchemaTypes.Mixed,
|
|
21
|
+
typeOf: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
itemListElement: [mongoose.SchemaTypes.Mixed],
|
|
26
|
+
itemOffered: mongoose.SchemaTypes.Mixed,
|
|
27
|
+
additionalProperty: [mongoose.SchemaTypes.Mixed]
|
|
15
28
|
}, {
|
|
16
29
|
collection: 'offerCatalogs',
|
|
17
30
|
id: true,
|
|
18
31
|
read: 'primaryPreferred',
|
|
19
32
|
writeConcern: writeConcern,
|
|
20
|
-
strict:
|
|
33
|
+
strict: true,
|
|
21
34
|
timestamps: {
|
|
22
35
|
createdAt: 'createdAt',
|
|
23
36
|
updatedAt: 'updatedAt'
|
|
@@ -62,6 +75,12 @@ schema.index({ 'itemOffered.serviceType.codeValue': 1, identifier: 1 }, {
|
|
|
62
75
|
'itemOffered.serviceType.codeValue': { $exists: true }
|
|
63
76
|
}
|
|
64
77
|
});
|
|
78
|
+
schema.index({ additionalProperty: 1, identifier: 1 }, {
|
|
79
|
+
name: 'searchByAdditionalProperty',
|
|
80
|
+
partialFilterExpression: {
|
|
81
|
+
additionalProperty: { $exists: true }
|
|
82
|
+
}
|
|
83
|
+
});
|
|
65
84
|
mongoose.model(modelName, schema)
|
|
66
85
|
.on('index',
|
|
67
86
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -5,18 +5,6 @@ const mongoose = require("mongoose");
|
|
|
5
5
|
const modelName = 'OwnershipInfo';
|
|
6
6
|
exports.modelName = modelName;
|
|
7
7
|
const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
|
|
8
|
-
// Arrayにも対応するためにMixedに変更(2022-07-26~)
|
|
9
|
-
const ownedBySchema = mongoose.SchemaTypes.Mixed;
|
|
10
|
-
const acquiredFromSchema = new mongoose.Schema({}, {
|
|
11
|
-
id: false,
|
|
12
|
-
_id: false,
|
|
13
|
-
strict: false
|
|
14
|
-
});
|
|
15
|
-
const typeOfGoodSchema = new mongoose.Schema({}, {
|
|
16
|
-
id: false,
|
|
17
|
-
_id: false,
|
|
18
|
-
strict: false
|
|
19
|
-
});
|
|
20
8
|
/**
|
|
21
9
|
* 所有権スキーマ
|
|
22
10
|
*/
|
|
@@ -28,11 +16,11 @@ const schema = new mongoose.Schema({
|
|
|
28
16
|
required: true
|
|
29
17
|
},
|
|
30
18
|
identifier: mongoose.SchemaTypes.Mixed,
|
|
31
|
-
ownedBy:
|
|
32
|
-
acquiredFrom:
|
|
19
|
+
ownedBy: mongoose.SchemaTypes.Mixed,
|
|
20
|
+
acquiredFrom: mongoose.SchemaTypes.Mixed,
|
|
33
21
|
ownedFrom: Date,
|
|
34
22
|
ownedThrough: Date,
|
|
35
|
-
typeOfGood:
|
|
23
|
+
typeOfGood: mongoose.SchemaTypes.Mixed
|
|
36
24
|
}, {
|
|
37
25
|
collection: 'ownershipInfos',
|
|
38
26
|
id: true,
|
|
@@ -113,6 +113,24 @@ schema.index({ additionalProperty: 1, branchCode: 1 }, {
|
|
|
113
113
|
additionalProperty: { $exists: true }
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
|
+
schema.index({ 'containsPlace.additionalProperty': 1, branchCode: 1 }, {
|
|
117
|
+
name: 'searchByContainsPlaceAdditionalProperty',
|
|
118
|
+
partialFilterExpression: {
|
|
119
|
+
'containsPlace.additionalProperty': { $exists: true }
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
schema.index({ 'containsPlace.containsPlace.additionalProperty': 1, branchCode: 1 }, {
|
|
123
|
+
name: 'searchByContainsPlaceContainsPlaceAdditionalProperty',
|
|
124
|
+
partialFilterExpression: {
|
|
125
|
+
'containsPlace.containsPlace.additionalProperty': { $exists: true }
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
schema.index({ 'containsPlace.containsPlace.containsPlace.additionalProperty': 1, branchCode: 1 }, {
|
|
129
|
+
name: 'searchByContainsPlaceContainsPlaceContainsPlaceAdditionalProperty',
|
|
130
|
+
partialFilterExpression: {
|
|
131
|
+
'containsPlace.containsPlace.containsPlace.additionalProperty': { $exists: true }
|
|
132
|
+
}
|
|
133
|
+
});
|
|
116
134
|
mongoose.model(modelName, schema)
|
|
117
135
|
.on('index',
|
|
118
136
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -32,7 +32,7 @@ class MongoRepository {
|
|
|
32
32
|
this.offerCatalogModel = connection.model(offerCatalog_1.modelName);
|
|
33
33
|
}
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
36
36
|
// MongoDB検索条件
|
|
37
37
|
const andConditions = [];
|
|
38
38
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -107,15 +107,15 @@ class MongoRepository {
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
111
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
112
|
+
andConditions.push({
|
|
113
|
+
additionalProperty: {
|
|
114
|
+
$exists: true,
|
|
115
|
+
$elemMatch: additionalPropertyElemMatch
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
119
|
return andConditions;
|
|
120
120
|
}
|
|
121
121
|
save(params) {
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -435,7 +435,7 @@ class MongoRepository {
|
|
|
435
435
|
}
|
|
436
436
|
// tslint:disable-next-line:max-func-body-length
|
|
437
437
|
searchScreeningRoomSections(searchConditions) {
|
|
438
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
438
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
439
439
|
return __awaiter(this, void 0, void 0, function* () {
|
|
440
440
|
const matchStages = [];
|
|
441
441
|
if (searchConditions.project !== undefined) {
|
|
@@ -517,6 +517,17 @@ class MongoRepository {
|
|
|
517
517
|
}
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
|
+
const additionalPropertyElemMatch = (_j = searchConditions.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
|
|
521
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
522
|
+
matchStages.push({
|
|
523
|
+
$match: {
|
|
524
|
+
'containsPlace.containsPlace.additionalProperty': {
|
|
525
|
+
$exists: true,
|
|
526
|
+
$elemMatch: additionalPropertyElemMatch
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
520
531
|
const aggregate = this.placeModel.aggregate([
|
|
521
532
|
{ $unwind: '$containsPlace' },
|
|
522
533
|
{ $unwind: '$containsPlace.containsPlace' },
|
|
@@ -532,7 +543,7 @@ class MongoRepository {
|
|
|
532
543
|
branchCode: '$branchCode',
|
|
533
544
|
name: '$name'
|
|
534
545
|
}
|
|
535
|
-
}, additionalProperty: '$containsPlace.containsPlace.additionalProperty' }, (((
|
|
546
|
+
}, additionalProperty: '$containsPlace.containsPlace.additionalProperty' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.seatCount) === 1)
|
|
536
547
|
? {
|
|
537
548
|
seatCount: {
|
|
538
549
|
$cond: {
|
|
@@ -582,7 +593,7 @@ class MongoRepository {
|
|
|
582
593
|
}
|
|
583
594
|
// tslint:disable-next-line:max-func-body-length
|
|
584
595
|
searchScreeningRooms(searchConditions) {
|
|
585
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
596
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
586
597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
587
598
|
const matchStages = [];
|
|
588
599
|
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -671,6 +682,17 @@ class MongoRepository {
|
|
|
671
682
|
}
|
|
672
683
|
});
|
|
673
684
|
}
|
|
685
|
+
const additionalPropertyElemMatch = (_g = searchConditions.additionalProperty) === null || _g === void 0 ? void 0 : _g.$elemMatch;
|
|
686
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
687
|
+
matchStages.push({
|
|
688
|
+
$match: {
|
|
689
|
+
'containsPlace.additionalProperty': {
|
|
690
|
+
$exists: true,
|
|
691
|
+
$elemMatch: additionalPropertyElemMatch
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}
|
|
674
696
|
const aggregate = this.placeModel.aggregate([
|
|
675
697
|
{ $unwind: '$containsPlace' },
|
|
676
698
|
...matchStages,
|
|
@@ -680,7 +702,7 @@ class MongoRepository {
|
|
|
680
702
|
typeOf: '$typeOf',
|
|
681
703
|
branchCode: '$branchCode',
|
|
682
704
|
name: '$name'
|
|
683
|
-
}, openSeatingAllowed: '$containsPlace.openSeatingAllowed', additionalProperty: '$containsPlace.additionalProperty' }, (((
|
|
705
|
+
}, openSeatingAllowed: '$containsPlace.openSeatingAllowed', additionalProperty: '$containsPlace.additionalProperty' }, (((_h = searchConditions.$projection) === null || _h === void 0 ? void 0 : _h.sectionCount) === 1)
|
|
684
706
|
? {
|
|
685
707
|
sectionCount: {
|
|
686
708
|
$cond: {
|
|
@@ -690,7 +712,7 @@ class MongoRepository {
|
|
|
690
712
|
}
|
|
691
713
|
}
|
|
692
714
|
}
|
|
693
|
-
: undefined), (((
|
|
715
|
+
: undefined), (((_j = searchConditions.$projection) === null || _j === void 0 ? void 0 : _j.seatCount) === 1)
|
|
694
716
|
? {
|
|
695
717
|
seatCount: {
|
|
696
718
|
$sum: {
|
|
@@ -833,7 +855,7 @@ class MongoRepository {
|
|
|
833
855
|
}
|
|
834
856
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
835
857
|
searchSeats(params) {
|
|
836
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
858
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
837
859
|
return __awaiter(this, void 0, void 0, function* () {
|
|
838
860
|
const matchStages = [];
|
|
839
861
|
if (params.project !== undefined) {
|
|
@@ -971,6 +993,17 @@ class MongoRepository {
|
|
|
971
993
|
&& params.$projection['containedInPlace.containedInPlace'] === 0) {
|
|
972
994
|
includeScreeningRooms = false;
|
|
973
995
|
}
|
|
996
|
+
const additionalPropertyElemMatch = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
|
|
997
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
998
|
+
matchStages.push({
|
|
999
|
+
$match: {
|
|
1000
|
+
'containsPlace.containsPlace.containsPlace.additionalProperty': {
|
|
1001
|
+
$exists: true,
|
|
1002
|
+
$elemMatch: additionalPropertyElemMatch
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
974
1007
|
const aggregate = this.placeModel.aggregate([
|
|
975
1008
|
{ $unwind: '$containsPlace' },
|
|
976
1009
|
{ $unwind: '$containsPlace.containsPlace' },
|
|
@@ -475,7 +475,7 @@ function createScreeningEventAdditionalPropertyFromCOA(params) {
|
|
|
475
475
|
return {
|
|
476
476
|
coaInfo,
|
|
477
477
|
additionalProperty: [
|
|
478
|
-
{ name: 'COA_ENDPOINT', value:
|
|
478
|
+
// { name: 'COA_ENDPOINT', value: credentials.coa.endpoint },
|
|
479
479
|
{ name: 'coaInfo', value: JSON.stringify(coaInfo) }
|
|
480
480
|
]
|
|
481
481
|
};
|
|
@@ -579,7 +579,7 @@ function createScreeningEventSeriesAdditionalPropertyFromCOA(params) {
|
|
|
579
579
|
return {
|
|
580
580
|
coaInfo,
|
|
581
581
|
additionalProperty: [
|
|
582
|
-
{ name: 'COA_ENDPOINT', value:
|
|
582
|
+
// { name: 'COA_ENDPOINT', value: credentials.coa.endpoint },
|
|
583
583
|
{ name: 'coaInfo', value: JSON.stringify(coaInfo) }
|
|
584
584
|
]
|
|
585
585
|
};
|
|
@@ -82,7 +82,6 @@ function responseBody2acceptedOffers4result(params) {
|
|
|
82
82
|
coaInfo = event.coaInfo;
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
// const coaEndpointProperty = event.additionalProperty.find((p) => p.name === 'COA_ENDPOINT');
|
|
86
85
|
const coaInfoProperty = (_a = event.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'coaInfo');
|
|
87
86
|
coaInfo = (coaInfoProperty !== undefined) ? JSON.parse(coaInfoProperty.value) : undefined;
|
|
88
87
|
}
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.279.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.134.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.279.0-alpha.5",
|
|
13
|
+
"@cinerino/sdk": "3.134.0-alpha.4",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.1.0-alpha.
|
|
123
|
+
"version": "20.1.0-alpha.28"
|
|
124
124
|
}
|
|
@@ -1,71 +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
|
-
const DEFAULT_TRANSACTION_DURATION = 900;
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
12
|
-
|
|
13
|
-
const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
14
|
-
|
|
15
|
-
const cursor = sellerRepo.getCursor(
|
|
16
|
-
{
|
|
17
|
-
// 'project.id': { $eq: project.id }
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
// _id: 1,
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
console.log('sellers found');
|
|
24
|
-
|
|
25
|
-
let i = 0;
|
|
26
|
-
let updateCount = 0;
|
|
27
|
-
await cursor.eachAsync(async (doc) => {
|
|
28
|
-
i += 1;
|
|
29
|
-
const seller: chevre.factory.seller.ISeller = doc.toObject();
|
|
30
|
-
|
|
31
|
-
const makesOffer = seller.makesOffer;
|
|
32
|
-
|
|
33
|
-
if (Array.isArray(makesOffer) && makesOffer.length > 0) {
|
|
34
|
-
const everyMakesHasTransactionDuration = makesOffer.every((offer) => {
|
|
35
|
-
const transactionDuration = offer.eligibleTransactionDuration?.maxValue;
|
|
36
|
-
|
|
37
|
-
return typeof transactionDuration === 'number';
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (everyMakesHasTransactionDuration) {
|
|
41
|
-
console.log(
|
|
42
|
-
'already migrated...', seller.project.id, seller.id, makesOffer.length, i);
|
|
43
|
-
} else {
|
|
44
|
-
const eligibleTransactionDuration: chevre.factory.seller.IEligibleTransactionDuration = {
|
|
45
|
-
typeOf: 'QuantitativeValue',
|
|
46
|
-
unitCode: chevre.factory.unitCode.Sec,
|
|
47
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
48
|
-
maxValue: (seller.project.id.slice(0, 6) === 'sskts-') ? 600 : DEFAULT_TRANSACTION_DURATION
|
|
49
|
-
};
|
|
50
|
-
console.log(
|
|
51
|
-
'updating seller...', seller.project.id, seller.id, i);
|
|
52
|
-
await sellerRepo.save({
|
|
53
|
-
id: seller.id,
|
|
54
|
-
attributes: <any>{
|
|
55
|
-
'makesOffer.$[].eligibleTransactionDuration': eligibleTransactionDuration
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
updateCount += 1;
|
|
59
|
-
console.log(
|
|
60
|
-
'updated...', seller.project.id, seller.id, i);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
console.log(i, 'sellers checked');
|
|
66
|
-
console.log(updateCount, 'sellers updated');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
main()
|
|
70
|
-
.then()
|
|
71
|
-
.catch(console.error);
|