@chevre/domain 21.2.0-alpha.126 → 21.2.0-alpha.128
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/searchHoldReservations.ts +31 -0
- package/lib/chevre/repo/stockHolder.d.ts +16 -1
- package/lib/chevre/repo/stockHolder.js +9 -1
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +4 -1
- package/package.json +1 -1
- package/example/src/chevre/migrateStockHolderKeys.ts +0 -89
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as redis from 'redis';
|
|
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, { autoIndex: false });
|
|
10
|
+
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
11
|
+
socket: {
|
|
12
|
+
host: process.env.REDIS_HOST,
|
|
13
|
+
port: Number(process.env.REDIS_PORT)
|
|
14
|
+
},
|
|
15
|
+
password: process.env.REDIS_KEY
|
|
16
|
+
});
|
|
17
|
+
await client.connect();
|
|
18
|
+
|
|
19
|
+
const stockHolderRepo = new chevre.repository.StockHolder(client, mongoose.connection);
|
|
20
|
+
|
|
21
|
+
const holdReservations = await stockHolderRepo.search({
|
|
22
|
+
limit: 100,
|
|
23
|
+
page: 1
|
|
24
|
+
});
|
|
25
|
+
console.log(holdReservations[0]?.reservationFor.aggregateReservation, holdReservations[0]?.objectSize);
|
|
26
|
+
console.log(holdReservations.length);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main()
|
|
30
|
+
.then(console.log)
|
|
31
|
+
.catch(console.error);
|
|
@@ -62,6 +62,21 @@ export interface ISearchSubReservationResult {
|
|
|
62
62
|
reservationNumber: string;
|
|
63
63
|
identifier: string;
|
|
64
64
|
}
|
|
65
|
+
export interface ISearchResult {
|
|
66
|
+
reservationNumber: string;
|
|
67
|
+
identifier: string;
|
|
68
|
+
reservationFor: {
|
|
69
|
+
id: string;
|
|
70
|
+
startDate: Date;
|
|
71
|
+
aggregateReservation: {
|
|
72
|
+
reservationCount: number;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
reservedTicket?: {
|
|
76
|
+
ticketedSeat?: Pick<factory.reservation.ISeat<factory.reservationType>, 'seatNumber' | 'seatSection'>;
|
|
77
|
+
};
|
|
78
|
+
objectSize?: number;
|
|
79
|
+
}
|
|
65
80
|
/**
|
|
66
81
|
* イベントストックホルダーリポジトリ
|
|
67
82
|
*/
|
|
@@ -158,7 +173,7 @@ export declare class StockHolderRepository {
|
|
|
158
173
|
};
|
|
159
174
|
};
|
|
160
175
|
};
|
|
161
|
-
}): Promise<
|
|
176
|
+
}): Promise<ISearchResult[]>;
|
|
162
177
|
private checkIfConflicted;
|
|
163
178
|
private initializeHoldReservation;
|
|
164
179
|
}
|
|
@@ -75,12 +75,19 @@ class StockHolderRepository {
|
|
|
75
75
|
* 新リポジトリを使用するかどうか
|
|
76
76
|
*/
|
|
77
77
|
static useMongoose(params) {
|
|
78
|
+
if (!(params.startDate instanceof Date)) {
|
|
79
|
+
throw new factory.errors.Argument('startDate', 'must be Date');
|
|
80
|
+
}
|
|
78
81
|
if (params.useMongooseForcibly === true) {
|
|
79
82
|
return true;
|
|
80
83
|
}
|
|
81
84
|
if (settings_1.USE_NEW_STOCK_HOLDER_REPO_IDS.includes(params.eventId)) {
|
|
82
85
|
return true;
|
|
83
86
|
}
|
|
87
|
+
if (moment(params.startDate)
|
|
88
|
+
.isSameOrAfter(settings_1.USE_NEW_STOCK_HOLDER_REPO_FROM)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
84
91
|
return false;
|
|
85
92
|
}
|
|
86
93
|
/**
|
|
@@ -534,7 +541,8 @@ class StockHolderRepository {
|
|
|
534
541
|
}
|
|
535
542
|
},
|
|
536
543
|
reservationNumber: '$reservations.reservationNumber',
|
|
537
|
-
reservedTicket: '$reservations.subReservation.reservedTicket'
|
|
544
|
+
reservedTicket: '$reservations.subReservation.reservedTicket',
|
|
545
|
+
objectSize: { $bsonSize: '$$ROOT' }
|
|
538
546
|
}
|
|
539
547
|
}
|
|
540
548
|
]);
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
|
39
39
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
40
40
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
41
41
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
42
|
+
export declare const USE_NEW_STOCK_HOLDER_REPO_FROM: moment.Moment;
|
|
42
43
|
export declare const USE_NEW_STOCK_HOLDER_REPO_IDS: string[];
|
|
43
44
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
44
45
|
export declare const MONGO_MAX_TIME_MS: number;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_NEW_STOCK_HOLDER_REPO_IDS = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_NEW_STOCK_HOLDER_REPO_IDS = exports.USE_NEW_STOCK_HOLDER_REPO_FROM = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -65,6 +65,9 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
|
|
|
65
65
|
exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
|
|
66
66
|
? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
|
|
67
67
|
: moment('2023-08-31T15:00:00Z');
|
|
68
|
+
exports.USE_NEW_STOCK_HOLDER_REPO_FROM = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_FROM === 'string')
|
|
69
|
+
? moment(process.env.USE_NEW_STOCK_HOLDER_REPO_FROM)
|
|
70
|
+
: moment('2023-11-30T15:00:00Z');
|
|
68
71
|
exports.USE_NEW_STOCK_HOLDER_REPO_IDS = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_IDS === 'string')
|
|
69
72
|
? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
|
|
70
73
|
: [];
|
package/package.json
CHANGED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
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
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
-
|
|
10
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
11
|
-
|
|
12
|
-
async function main() {
|
|
13
|
-
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
14
|
-
socket: {
|
|
15
|
-
host: process.env.REDIS_HOST,
|
|
16
|
-
port: Number(process.env.REDIS_PORT)
|
|
17
|
-
},
|
|
18
|
-
password: process.env.REDIS_KEY
|
|
19
|
-
});
|
|
20
|
-
await client.connect();
|
|
21
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
22
|
-
|
|
23
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
24
|
-
const stockHolderRepo = new chevre.repository.StockHolder(client, mongoose.connection);
|
|
25
|
-
|
|
26
|
-
const cursor = eventRepo.getCursor(
|
|
27
|
-
{
|
|
28
|
-
// 'project.id': { $eq: project.id },
|
|
29
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
30
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
31
|
-
startDate: {
|
|
32
|
-
$gte: moment('2023-04-23T15:00:00Z')
|
|
33
|
-
.toDate()
|
|
34
|
-
}
|
|
35
|
-
// _id: { $eq: 'al6aff83w' }
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
// _id: 1,
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
console.log('events found');
|
|
42
|
-
|
|
43
|
-
let i = 0;
|
|
44
|
-
let updateCount = 0;
|
|
45
|
-
await cursor.eachAsync(async (doc) => {
|
|
46
|
-
i += 1;
|
|
47
|
-
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
48
|
-
|
|
49
|
-
const oldKey = chevre.repository.StockHolder.GET_KEY({
|
|
50
|
-
eventId: event.id,
|
|
51
|
-
startDate: new Date()
|
|
52
|
-
});
|
|
53
|
-
const newKey = chevre.repository.StockHolder.GET_KEY({
|
|
54
|
-
eventId: event.id,
|
|
55
|
-
startDate: moment(event.startDate)
|
|
56
|
-
.toDate()
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
let conflicted = false;
|
|
60
|
-
try {
|
|
61
|
-
await stockHolderRepo.checkIfConflicted({
|
|
62
|
-
key: newKey,
|
|
63
|
-
eventId: event.id
|
|
64
|
-
});
|
|
65
|
-
} catch (error) {
|
|
66
|
-
conflicted = true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (conflicted) {
|
|
70
|
-
updateCount += 1;
|
|
71
|
-
await stockHolderRepo.migrateKey({
|
|
72
|
-
key: newKey,
|
|
73
|
-
eventId: event.id
|
|
74
|
-
});
|
|
75
|
-
console.log(
|
|
76
|
-
'updated...', event.project.id, event.id, event.startDate, i);
|
|
77
|
-
} else {
|
|
78
|
-
console.log(
|
|
79
|
-
'already exist...', event.project.id, event.id, event.startDate, i);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
console.log(i, 'events checked');
|
|
84
|
-
console.log(updateCount, 'events updated');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
main()
|
|
88
|
-
.then()
|
|
89
|
-
.catch(console.error);
|