@chevre/domain 21.5.0-alpha.4 → 21.5.0-alpha.5
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.
|
@@ -4,7 +4,7 @@ import * as mongoose from 'mongoose';
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
6
|
export async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
|
|
8
8
|
|
|
9
9
|
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
10
10
|
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
@@ -0,0 +1,70 @@
|
|
|
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 creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = creativeWorkRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
'offers.availabilityEnds': { $exists: true }
|
|
19
|
+
},
|
|
20
|
+
{}
|
|
21
|
+
);
|
|
22
|
+
console.log('creativeWorks found');
|
|
23
|
+
|
|
24
|
+
let i = 0;
|
|
25
|
+
let updateCount = 0;
|
|
26
|
+
let datePublishedUndefinedCount = 0;
|
|
27
|
+
await cursor.eachAsync(async (doc) => {
|
|
28
|
+
i += 1;
|
|
29
|
+
const movie: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
|
|
30
|
+
|
|
31
|
+
const availabilityEnds = movie.offers.availabilityEnds;
|
|
32
|
+
let availabilityStarts = movie.offers.availabilityStarts;
|
|
33
|
+
const createdAt: Date = (<any>movie).createdAt;
|
|
34
|
+
if (!(createdAt instanceof Date)) {
|
|
35
|
+
throw new Error('createdAt not Date');
|
|
36
|
+
}
|
|
37
|
+
const alreadyMigrated = availabilityStarts instanceof Date;
|
|
38
|
+
|
|
39
|
+
if (alreadyMigrated) {
|
|
40
|
+
console.log('already exist...', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
|
|
41
|
+
} else {
|
|
42
|
+
if (movie.datePublished === undefined) {
|
|
43
|
+
console.error('movie.datePublished undefined', movie.project.id, movie.id, movie.identifier, i);
|
|
44
|
+
// throw new Error('movie.datePublished undefined');
|
|
45
|
+
datePublishedUndefinedCount += 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
availabilityStarts = (movie.datePublished !== undefined)
|
|
49
|
+
? moment(movie.datePublished)
|
|
50
|
+
.toDate()
|
|
51
|
+
: moment(createdAt)
|
|
52
|
+
.toDate();
|
|
53
|
+
console.log('updating movie...', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
|
|
54
|
+
await creativeWorkRepo.saveMovie(<any>{
|
|
55
|
+
id: String(movie.id),
|
|
56
|
+
'offers.availabilityStarts': availabilityStarts
|
|
57
|
+
});
|
|
58
|
+
updateCount += 1;
|
|
59
|
+
console.log('updated.', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
console.log(i, 'creativeWorks checked');
|
|
64
|
+
console.log(updateCount, 'creativeWorks updated');
|
|
65
|
+
console.log(datePublishedUndefinedCount, 'datePublishedUndefinedCount');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main()
|
|
69
|
+
.then()
|
|
70
|
+
.catch(console.error);
|
|
@@ -33,7 +33,7 @@ class MongoRepository {
|
|
|
33
33
|
}
|
|
34
34
|
// tslint:disable-next-line:max-func-body-length
|
|
35
35
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
37
37
|
// MongoDB検索条件
|
|
38
38
|
const andConditions = [
|
|
39
39
|
{
|
|
@@ -140,31 +140,15 @@ class MongoRepository {
|
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
'offers.availabilityEnds': {
|
|
151
|
-
$exists: true,
|
|
152
|
-
$gte: params.offers.availableFrom
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
157
|
-
/* istanbul ignore else */
|
|
158
|
-
if (params.offers.availableThrough instanceof Date) {
|
|
159
|
-
andConditions.push({
|
|
160
|
-
'offers.availabilityStarts': {
|
|
161
|
-
$exists: true,
|
|
162
|
-
$lte: params.offers.availableThrough
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
143
|
+
const offersAvailableFrom = (_k = params.offers) === null || _k === void 0 ? void 0 : _k.availableFrom;
|
|
144
|
+
if (offersAvailableFrom instanceof Date) {
|
|
145
|
+
andConditions.push({ 'offers.availabilityEnds': { $exists: true, $gte: offersAvailableFrom } });
|
|
146
|
+
}
|
|
147
|
+
const offersAvailableThrough = (_l = params.offers) === null || _l === void 0 ? void 0 : _l.availableThrough;
|
|
148
|
+
if (offersAvailableThrough instanceof Date) {
|
|
149
|
+
andConditions.push({ 'offers.availabilityStarts': { $exists: true, $lte: offersAvailableThrough } });
|
|
166
150
|
}
|
|
167
|
-
const additionalPropertyElemMatch = (
|
|
151
|
+
const additionalPropertyElemMatch = (_m = params.additionalProperty) === null || _m === void 0 ? void 0 : _m.$elemMatch;
|
|
168
152
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
169
153
|
andConditions.push({
|
|
170
154
|
additionalProperty: {
|
|
@@ -37,7 +37,7 @@ function createEvent(params) {
|
|
|
37
37
|
const firstCreatingEventParams = creatingEventParams[0];
|
|
38
38
|
const movieTheaters = yield repos.place.searchMovieTheaters({
|
|
39
39
|
project: { id: { $eq: actionAttributes.project.id } }
|
|
40
|
-
}, ['_id', 'branchCode', 'kanaName', 'name'], []);
|
|
40
|
+
}, ['_id', 'branchCode', 'kanaName', 'name', 'parentOrganization'], []);
|
|
41
41
|
creatingEventParams = movieTheaters.map((movieTheater) => {
|
|
42
42
|
const location = {
|
|
43
43
|
branchCode: movieTheater.branchCode,
|
|
@@ -46,8 +46,13 @@ function createEvent(params) {
|
|
|
46
46
|
name: movieTheater.name,
|
|
47
47
|
typeOf: factory.placeType.MovieTheater
|
|
48
48
|
};
|
|
49
|
+
const organizer = {
|
|
50
|
+
id: movieTheater.parentOrganization.id
|
|
51
|
+
};
|
|
49
52
|
return {
|
|
50
|
-
attributes: Object.assign(Object.assign({}, firstCreatingEventParams.attributes), { location
|
|
53
|
+
attributes: Object.assign(Object.assign({}, firstCreatingEventParams.attributes), { location,
|
|
54
|
+
// organizerがfirstCreatingEventParamsにそろってしまうbug対応(2023-08-03~)
|
|
55
|
+
organizer })
|
|
51
56
|
};
|
|
52
57
|
});
|
|
53
58
|
}
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.321.
|
|
13
|
-
"@cinerino/sdk": "3.162.
|
|
12
|
+
"@chevre/factory": "4.321.1",
|
|
13
|
+
"@cinerino/sdk": "3.162.1",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.5.0-alpha.
|
|
120
|
+
"version": "21.5.0-alpha.5"
|
|
121
121
|
}
|