@chevre/domain 20.1.0-alpha.27 → 20.1.0-alpha.29
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/migrateAccountTitleAdditionalProperties.ts +157 -0
- package/example/src/chevre/migrateCreativeWorkAdditionalProperties.ts +8 -4
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +162 -0
- package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +64 -0
- package/example/src/chevre/migrateSection.ts +105 -0
- package/lib/chevre/repo/accountAction.d.ts +0 -18
- package/lib/chevre/repo/accountAction.js +402 -355
- package/lib/chevre/repo/accountTitle.d.ts +1 -0
- package/lib/chevre/repo/accountTitle.js +6 -1
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -0
- package/lib/chevre/repo/merchantReturnPolicy.js +5 -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/package.json +3 -3
- package/example/src/chevre/migrateSSKTSEventCOAEndpoint.ts +0 -71
|
@@ -0,0 +1,157 @@
|
|
|
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, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const accountTitleRepo = new chevre.repository.AccountTitle(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = accountTitleRepo.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('accountTitles found');
|
|
29
|
+
|
|
30
|
+
const additionalPropertyNamesOnCategories: string[] = [];
|
|
31
|
+
const additionalPropertyNames: string[] = [];
|
|
32
|
+
const additionalPropertyNamesOnTitles: string[] = [];
|
|
33
|
+
const projectIdsOnCategories: string[] = [];
|
|
34
|
+
const projectIds: string[] = [];
|
|
35
|
+
const projectIdsOnTitles: string[] = [];
|
|
36
|
+
const unexpextedprojectIdsOnCategories: string[] = [];
|
|
37
|
+
const unexpextedprojectIds: string[] = [];
|
|
38
|
+
const unexpextedprojectIdsOnTitles: 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 accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
|
|
46
|
+
|
|
47
|
+
const additionalPropertyNamesOnCategory = accountTitleCategory.additionalProperty?.map((p) => p.name);
|
|
48
|
+
console.log(
|
|
49
|
+
(Array.isArray(additionalPropertyNamesOnCategory)) ? additionalPropertyNamesOnCategory.length : 0,
|
|
50
|
+
'additionalPropertyNamesOnCategory found',
|
|
51
|
+
accountTitleCategory.project.id,
|
|
52
|
+
accountTitleCategory.codeValue
|
|
53
|
+
);
|
|
54
|
+
if (Array.isArray(additionalPropertyNamesOnCategory) && additionalPropertyNamesOnCategory.length > 0) {
|
|
55
|
+
console.log(
|
|
56
|
+
additionalPropertyNamesOnCategory.length,
|
|
57
|
+
'additionalPropertyNamesOnResource found',
|
|
58
|
+
accountTitleCategory.project.id,
|
|
59
|
+
accountTitleCategory.codeValue
|
|
60
|
+
);
|
|
61
|
+
additionalPropertyNamesOnCategories.push(...additionalPropertyNamesOnCategory);
|
|
62
|
+
projectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
63
|
+
additionalPropertyNamesOnCategory.forEach((name) => {
|
|
64
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
65
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
66
|
+
unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
67
|
+
}
|
|
68
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
69
|
+
if (name.length < 5) {
|
|
70
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
71
|
+
unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (Array.isArray(accountTitleCategory.hasCategoryCode)) {
|
|
77
|
+
accountTitleCategory.hasCategoryCode.forEach((accountTitleSet) => {
|
|
78
|
+
const additionalPropertyNamesOnResource = accountTitleSet.additionalProperty?.map((p) => p.name);
|
|
79
|
+
console.log(
|
|
80
|
+
(Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
|
|
81
|
+
'additionalPropertyNamesOnResource found',
|
|
82
|
+
accountTitleCategory.project.id,
|
|
83
|
+
accountTitleCategory.codeValue
|
|
84
|
+
);
|
|
85
|
+
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
86
|
+
console.log(
|
|
87
|
+
additionalPropertyNamesOnResource.length,
|
|
88
|
+
'additionalPropertyNamesOnResource found',
|
|
89
|
+
accountTitleCategory.project.id,
|
|
90
|
+
accountTitleCategory.codeValue
|
|
91
|
+
);
|
|
92
|
+
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
93
|
+
projectIds.push(accountTitleCategory.project.id);
|
|
94
|
+
additionalPropertyNamesOnResource.forEach((name) => {
|
|
95
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
96
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
97
|
+
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
98
|
+
}
|
|
99
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
100
|
+
if (name.length < 5) {
|
|
101
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
102
|
+
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (Array.isArray(accountTitleSet.hasCategoryCode)) {
|
|
108
|
+
accountTitleSet.hasCategoryCode.forEach((accountTitl) => {
|
|
109
|
+
const additionalPropertyNamesOnSection = accountTitl.additionalProperty?.map((p) => p.name);
|
|
110
|
+
console.log(
|
|
111
|
+
(Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
|
|
112
|
+
'additionalPropertyNamesOnSection found',
|
|
113
|
+
accountTitleCategory.project.id,
|
|
114
|
+
accountTitleCategory.codeValue
|
|
115
|
+
);
|
|
116
|
+
if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
|
|
117
|
+
console.log(
|
|
118
|
+
additionalPropertyNamesOnSection.length,
|
|
119
|
+
'additionalPropertyNamesOnSection found',
|
|
120
|
+
accountTitleCategory.project.id,
|
|
121
|
+
accountTitleCategory.codeValue
|
|
122
|
+
);
|
|
123
|
+
additionalPropertyNamesOnTitles.push(...additionalPropertyNamesOnSection);
|
|
124
|
+
projectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
125
|
+
additionalPropertyNamesOnSection.forEach((name) => {
|
|
126
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
127
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
128
|
+
unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
129
|
+
}
|
|
130
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
131
|
+
if (name.length < 5) {
|
|
132
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
133
|
+
unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
console.log(i, 'places checked');
|
|
143
|
+
console.log(updateCount, 'places updated');
|
|
144
|
+
console.log([...new Set(additionalPropertyNamesOnCategories)], 'categories');
|
|
145
|
+
console.log([...new Set(projectIdsOnCategories)], 'categories');
|
|
146
|
+
console.log([...new Set(unexpextedprojectIdsOnCategories)], 'categories');
|
|
147
|
+
console.log([...new Set(additionalPropertyNames)], 'sets');
|
|
148
|
+
console.log([...new Set(projectIds)], 'sets');
|
|
149
|
+
console.log([...new Set(unexpextedprojectIds)], 'sets');
|
|
150
|
+
console.log([...new Set(additionalPropertyNamesOnTitles)], 'titles');
|
|
151
|
+
console.log([...new Set(projectIdsOnTitles)], 'titles');
|
|
152
|
+
console.log([...new Set(unexpextedprojectIdsOnTitles)], 'titles');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
main()
|
|
156
|
+
.then()
|
|
157
|
+
.catch(console.error);
|
|
@@ -9,24 +9,28 @@ const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
|
9
9
|
|
|
10
10
|
// tslint:disable-next-line:max-func-body-length
|
|
11
11
|
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
14
|
// const customerRepo = new chevre.repository.Customer(mongoose.connection);
|
|
15
15
|
// const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
16
16
|
// const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
17
|
-
const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
|
|
17
|
+
// const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
|
|
18
18
|
// const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
19
19
|
// const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
20
20
|
// const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
|
|
21
21
|
// const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
|
|
22
|
+
// const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
23
|
+
const merchantReturnPolicyRepo = new chevre.repository.MerchantReturnPolicy(mongoose.connection);
|
|
22
24
|
|
|
23
25
|
// const cursor = customerRepo.getCursor(
|
|
24
26
|
// const cursor = sellerRepo.getCursor(
|
|
25
27
|
// const cursor = eventRepo.getCursor(
|
|
26
28
|
// const cursor = categoryCodeRepo.getCursor(
|
|
27
29
|
// const cursor = offerRepo.getCursor(
|
|
28
|
-
const cursor = creativeWorkRepo.getCursor(
|
|
29
|
-
|
|
30
|
+
// const cursor = creativeWorkRepo.getCursor(
|
|
31
|
+
// const cursor = placeRepo.getCursor(
|
|
32
|
+
// const cursor = offerCatalogRepo.getCursor(
|
|
33
|
+
const cursor = merchantReturnPolicyRepo.getCursor(
|
|
30
34
|
{
|
|
31
35
|
// 'project.id': { $eq: project.id },
|
|
32
36
|
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
@@ -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, { autoIndex: false });
|
|
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,64 @@
|
|
|
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, { autoIndex: false });
|
|
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
|
+
// startDate: { $gte: new Date() }
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
// _id: 1,
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
console.log('events found');
|
|
26
|
+
|
|
27
|
+
let i = 0;
|
|
28
|
+
let updateCount = 0;
|
|
29
|
+
await cursor.eachAsync(async (doc) => {
|
|
30
|
+
i += 1;
|
|
31
|
+
const event: chevre.factory.event.IEvent<chevre.factory.eventType> = doc.toObject();
|
|
32
|
+
|
|
33
|
+
const coaEndpointPropert = event.additionalProperty?.find((p) => p.name === DELETING_PROPERTY_NAME);
|
|
34
|
+
|
|
35
|
+
if (coaEndpointPropert !== undefined) {
|
|
36
|
+
const newAdditionalProperty: chevre.factory.propertyValue.IPropertyValue<string>[] =
|
|
37
|
+
(Array.isArray(event.additionalProperty))
|
|
38
|
+
? event.additionalProperty.filter((p) => {
|
|
39
|
+
return p.name !== DELETING_PROPERTY_NAME;
|
|
40
|
+
})
|
|
41
|
+
: [];
|
|
42
|
+
console.log(
|
|
43
|
+
'updating event...', event.project.id, event.id, event.startDate, coaEndpointPropert.value, newAdditionalProperty, i);
|
|
44
|
+
await eventRepo.updatePartiallyById({
|
|
45
|
+
id: event.id,
|
|
46
|
+
attributes: <any>{
|
|
47
|
+
typeOf: event.typeOf,
|
|
48
|
+
additionalProperty: newAdditionalProperty
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
updateCount += 1;
|
|
52
|
+
console.log('event updated', event.project.id, event.id, event.startDate, i);
|
|
53
|
+
} else {
|
|
54
|
+
console.log('no property...', event.project.id, event.id, event.startDate, i);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
console.log(i, 'events checked');
|
|
59
|
+
console.log(updateCount, 'events updated');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
main()
|
|
63
|
+
.then()
|
|
64
|
+
.catch(console.error);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
import * as redis from 'redis';
|
|
5
|
+
|
|
6
|
+
import { chevre } from '../../../lib/index';
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const client = redis.createClient({
|
|
12
|
+
host: <string>process.env.REDIS_HOST,
|
|
13
|
+
port: Number(process.env.REDIS_PORT),
|
|
14
|
+
password: <string>process.env.REDIS_KEY
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
18
|
+
|
|
19
|
+
const events = await eventRepo.search({
|
|
20
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
21
|
+
project: { id: { $eq: '' } },
|
|
22
|
+
startFrom: new Date()
|
|
23
|
+
// startThrough: moment().add(4, 'day').toDate()
|
|
24
|
+
});
|
|
25
|
+
console.log(events.length, 'events found');
|
|
26
|
+
|
|
27
|
+
const sectionCode = 'Default';
|
|
28
|
+
await Promise.all(events.map(async (event) => {
|
|
29
|
+
await new Promise<void>((resolve) => {
|
|
30
|
+
const key = `chevre:itemAvailability:screeningEvent:${event.id}`;
|
|
31
|
+
client.hgetall(key, async (__, reply) => {
|
|
32
|
+
if (reply !== null && Object.keys(reply).length > 0) {
|
|
33
|
+
|
|
34
|
+
const fieldAndValues = reply;
|
|
35
|
+
for (const field of Object.keys(fieldAndValues)) {
|
|
36
|
+
// セクションがなければキーを更新
|
|
37
|
+
if (field.slice(0, 7) !== sectionCode) {
|
|
38
|
+
console.log(event.id, field);
|
|
39
|
+
const newField = `${sectionCode}${field}`;
|
|
40
|
+
const newValue = fieldAndValues[field];
|
|
41
|
+
console.log('saving...', newField, newValue);
|
|
42
|
+
|
|
43
|
+
await new Promise<void>((resolveSet) => {
|
|
44
|
+
client.hsetnx(key, newField, newValue, (___, setReply) => {
|
|
45
|
+
console.log('set', setReply, newField, newValue);
|
|
46
|
+
|
|
47
|
+
resolveSet();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// 元のフィールドを削除
|
|
52
|
+
await new Promise<void>((resolveSet) => {
|
|
53
|
+
client.hdel(key, field, (___, setReply) => {
|
|
54
|
+
console.log('deleted', setReply, field);
|
|
55
|
+
|
|
56
|
+
resolveSet();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
resolve();
|
|
64
|
+
// if (err !== null) {
|
|
65
|
+
// reject(err);
|
|
66
|
+
// } else {
|
|
67
|
+
// if (reply !== null) {
|
|
68
|
+
// client.ttl(targetKey, (ttlErr, ttl) => {
|
|
69
|
+
// console.log('ttl:', ttl);
|
|
70
|
+
// const args = Object.keys(reply)
|
|
71
|
+
// .reduce(
|
|
72
|
+
// (a, b) => {
|
|
73
|
+
// return [...a, b, reply[b]];
|
|
74
|
+
// },
|
|
75
|
+
// []
|
|
76
|
+
// );
|
|
77
|
+
// console.log(args.length, 'args ready');
|
|
78
|
+
|
|
79
|
+
// newClient.multi()
|
|
80
|
+
// .hmset(newKey, ...args)
|
|
81
|
+
// .expire(newKey, ttl)
|
|
82
|
+
// .exec((hmsetErr, reply) => {
|
|
83
|
+
// console.log('hmset result:', hmsetErr, reply);
|
|
84
|
+
// resolve();
|
|
85
|
+
// });
|
|
86
|
+
// });
|
|
87
|
+
// } else {
|
|
88
|
+
// console.error('targetKey not found');
|
|
89
|
+
// }
|
|
90
|
+
// }
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
// client.keys('chevre:itemAvailability:screeningEvent:*', async (err, reply) => {
|
|
96
|
+
// console.log(err, reply.length, 'keys found');
|
|
97
|
+
// const targetKeys = reply;
|
|
98
|
+
|
|
99
|
+
// });
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
main()
|
|
104
|
+
.then(console.log)
|
|
105
|
+
.catch(console.error);
|
|
@@ -9,46 +9,28 @@ export declare type IAction<T extends factory.actionType> = T extends factory.ac
|
|
|
9
9
|
export declare class MongoRepository {
|
|
10
10
|
private readonly actionModel;
|
|
11
11
|
constructor(connection: Connection);
|
|
12
|
-
static CREATE_MONEY_TRANSFER_ACTIONS_MONGO_CONDITIONS(params: factory.account.action.moneyTransfer.ISearchConditions): any[];
|
|
13
12
|
/**
|
|
14
13
|
* アクション開始
|
|
15
14
|
*/
|
|
16
|
-
startByIdentifier<T extends factory.actionType>(params: factory.account.action.moneyTransfer.IAttributes): Promise<IAction<T>>;
|
|
17
15
|
/**
|
|
18
16
|
* アクション完了
|
|
19
17
|
*/
|
|
20
|
-
complete<T extends factory.actionType>(typeOf: T, actionId: string, result: any): Promise<IAction<T>>;
|
|
21
18
|
/**
|
|
22
19
|
* アクション中止
|
|
23
20
|
*/
|
|
24
|
-
cancel<T extends factory.actionType>(typeOf: T, actionId: string): Promise<IAction<T>>;
|
|
25
21
|
/**
|
|
26
22
|
* アクション失敗
|
|
27
23
|
*/
|
|
28
|
-
giveUp<T extends factory.actionType>(typeOf: T, actionId: string, error: any): Promise<IAction<T>>;
|
|
29
24
|
/**
|
|
30
25
|
* アクション検索
|
|
31
26
|
*/
|
|
32
|
-
findById<T extends factory.actionType>(typeOf: T, actionId: string): Promise<IAction<T>>;
|
|
33
|
-
countTransferActions(params: factory.account.action.moneyTransfer.ISearchConditions): Promise<number>;
|
|
34
27
|
/**
|
|
35
28
|
* 転送アクションを検索する
|
|
36
29
|
*/
|
|
37
|
-
searchTransferActions(params: factory.account.action.moneyTransfer.ISearchConditions): Promise<factory.account.action.moneyTransfer.IAction[]>;
|
|
38
30
|
/**
|
|
39
31
|
* アクションを検索する
|
|
40
32
|
* @param searchConditions 検索条件
|
|
41
33
|
*/
|
|
42
|
-
search<T extends factory.actionType>(searchConditions: {
|
|
43
|
-
typeOf: T;
|
|
44
|
-
actionStatuses?: factory.account.AccountStatusType[];
|
|
45
|
-
startDateFrom?: Date;
|
|
46
|
-
startDateThrough?: Date;
|
|
47
|
-
purposeTypeOfs?: factory.account.transactionType[];
|
|
48
|
-
fromLocationAccountNumbers?: string[];
|
|
49
|
-
toLocationAccountNumbers?: string[];
|
|
50
|
-
limit: number;
|
|
51
|
-
}): Promise<IAction<T>[]>;
|
|
52
34
|
clean(params: {
|
|
53
35
|
project?: {
|
|
54
36
|
id?: string;
|