@chevre/domain 21.2.0-alpha.2 → 21.2.0-alpha.21
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/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/countDelayedTasks.ts +17 -0
- package/example/src/chevre/countDelayedTransactions.ts +60 -0
- package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
- package/example/src/chevre/lockStockHolder.ts +48 -0
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
- package/example/src/chevre/processReserve.ts +2 -2
- package/example/src/chevre/searchEventSeats.ts +42 -0
- package/example/src/chevre/transaction/findCreditCard.ts +1 -1
- package/example/src/chevre/transaction/makeExpired.ts +18 -0
- package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
- package/example/src/chevre/transaction/startExportTasks.ts +19 -0
- package/example/src/chevre/updateTransaction.ts +1 -1
- package/lib/chevre/eventEmitter/task.d.ts +18 -0
- package/lib/chevre/eventEmitter/task.js +28 -0
- package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/transaction.js +28 -0
- package/lib/chevre/eventEmitter.d.ts +3 -0
- package/lib/chevre/eventEmitter.js +7 -0
- package/lib/chevre/index.d.ts +3 -2
- package/lib/chevre/index.js +5 -3
- package/lib/chevre/repo/account.js +0 -4
- package/lib/chevre/repo/accountTitle.js +0 -4
- package/lib/chevre/repo/accountTransaction.d.ts +0 -10
- package/lib/chevre/repo/accountTransaction.js +0 -57
- package/lib/chevre/repo/accountingReport.js +0 -4
- package/lib/chevre/repo/action.js +0 -4
- package/lib/chevre/repo/additionalProperty.js +0 -4
- package/lib/chevre/repo/aggregation.js +0 -4
- package/lib/chevre/repo/assetTransaction.d.ts +4 -6
- package/lib/chevre/repo/assetTransaction.js +69 -45
- package/lib/chevre/repo/categoryCode.js +0 -4
- package/lib/chevre/repo/code.js +0 -4
- package/lib/chevre/repo/comment.js +0 -4
- package/lib/chevre/repo/confirmationNumber.js +1 -1
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/creativeWork.js +0 -4
- package/lib/chevre/repo/customer.js +0 -4
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/emailMessage.js +0 -4
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/event.js +0 -4
- package/lib/chevre/repo/member.js +0 -4
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +42 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
- package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
- package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
- package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
- package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +62 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +38 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
- package/lib/chevre/repo/offer.js +0 -5
- package/lib/chevre/repo/offerCatalog.js +0 -4
- package/lib/chevre/repo/order.d.ts +25 -0
- package/lib/chevre/repo/order.js +5 -4
- package/lib/chevre/repo/orderNumber.d.ts +0 -1
- package/lib/chevre/repo/orderNumber.js +2 -12
- package/lib/chevre/repo/ownershipInfo.js +0 -4
- package/lib/chevre/repo/permit.js +0 -4
- package/lib/chevre/repo/place.d.ts +5 -1
- package/lib/chevre/repo/place.js +1 -10
- package/lib/chevre/repo/priceSpecification.js +0 -4
- package/lib/chevre/repo/product.js +0 -4
- package/lib/chevre/repo/project.js +0 -4
- package/lib/chevre/repo/rateLimit/offer.d.ts +3 -2
- package/lib/chevre/repo/rateLimit/offer.js +14 -14
- package/lib/chevre/repo/reservation.js +0 -4
- package/lib/chevre/repo/role.js +0 -4
- package/lib/chevre/repo/seller.js +0 -4
- package/lib/chevre/repo/serviceOutput.js +0 -4
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +2 -1
- package/lib/chevre/repo/serviceOutputIdentifier.js +14 -15
- package/lib/chevre/repo/{itemAvailability/screeningEvent.d.ts → stockHolder.d.ts} +5 -6
- package/lib/chevre/repo/stockHolder.js +273 -0
- package/lib/chevre/repo/task.d.ts +17 -2
- package/lib/chevre/repo/task.js +61 -10
- package/lib/chevre/repo/telemetry.js +0 -4
- package/lib/chevre/repo/transaction.d.ts +3 -2
- package/lib/chevre/repo/transaction.js +116 -54
- package/lib/chevre/repo/transactionNumber.d.ts +2 -1
- package/lib/chevre/repo/transactionNumber.js +14 -15
- package/lib/chevre/repo/trip.js +0 -4
- package/lib/chevre/repository.d.ts +3 -5
- package/lib/chevre/repository.js +5 -8
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +4 -3
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -5
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/assetTransaction/pay.js +2 -2
- package/lib/chevre/service/assetTransaction/refund.js +1 -1
- package/lib/chevre/service/assetTransaction/registerService.js +1 -2
- package/lib/chevre/service/assetTransaction/reserve.d.ts +4 -4
- package/lib/chevre/service/assetTransaction/reserve.js +8 -5
- package/lib/chevre/service/assetTransaction.d.ts +0 -2
- package/lib/chevre/service/assetTransaction.js +0 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
- package/lib/chevre/service/offer.d.ts +2 -2
- package/lib/chevre/service/offer.js +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -1
- package/lib/chevre/service/order/placeOrder.js +1 -1
- package/lib/chevre/service/order/returnOrder.js +1 -5
- package/lib/chevre/service/order/sendOrder.js +1 -1
- package/lib/chevre/service/payment/any.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.d.ts +3 -3
- package/lib/chevre/service/reserve/cancelReservation.js +6 -6
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -2
- package/lib/chevre/service/task/cancelPendingReservation.js +3 -3
- package/lib/chevre/service/task/cancelReservation.js +3 -3
- package/lib/chevre/service/task/voidReserveTransaction.js +3 -3
- package/lib/chevre/service/task.d.ts +9 -0
- package/lib/chevre/service/task.js +22 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -3
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
- package/lib/chevre/service/transaction/returnOrder.js +1 -5
- package/lib/chevre/service/transaction.d.ts +1 -0
- package/lib/chevre/service/transaction.js +1 -7
- package/lib/chevre/settings.d.ts +2 -1
- package/lib/chevre/settings.js +5 -4
- package/package.json +4 -4
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
- package/lib/chevre/repo/itemAvailability/screeningEvent.js +0 -193
|
@@ -387,13 +387,14 @@ function filterByEligibleSeatingType(params) {
|
|
|
387
387
|
const maximumAttendeeCapacity = eligibleSeatOffers.length;
|
|
388
388
|
let remainingAttendeeCapacity;
|
|
389
389
|
if (maximumAttendeeCapacity > 0) {
|
|
390
|
-
const availabilities = yield repos.
|
|
390
|
+
const availabilities = yield repos.stockHolder.searchHolders({
|
|
391
391
|
eventId: params.event.id,
|
|
392
392
|
startDate: moment(params.event.startDate)
|
|
393
393
|
.toDate(),
|
|
394
394
|
offers: eligibleSeatOffers
|
|
395
395
|
});
|
|
396
|
-
remainingAttendeeCapacity = availabilities.filter((a) => a.availability === factory.itemAvailability.InStock).length;
|
|
396
|
+
// remainingAttendeeCapacity = availabilities.filter((a) => a.availability === factory.itemAvailability.InStock).length;
|
|
397
|
+
remainingAttendeeCapacity = availabilities.filter((holder) => typeof holder !== 'string').length;
|
|
397
398
|
}
|
|
398
399
|
else {
|
|
399
400
|
remainingAttendeeCapacity = 0;
|
|
@@ -438,7 +439,7 @@ function aggregateReservationByEvent(params) {
|
|
|
438
439
|
// remainingAttendeeCapacityを決定
|
|
439
440
|
if (typeof maximumAttendeeCapacity === 'number') {
|
|
440
441
|
// 残席数を座席ロック数から計算
|
|
441
|
-
const unavailableOfferCount = yield repos.
|
|
442
|
+
const unavailableOfferCount = yield repos.stockHolder.countUnavailableOffers({
|
|
442
443
|
event: {
|
|
443
444
|
id: params.event.id,
|
|
444
445
|
startDate: moment(params.event.startDate)
|
|
@@ -13,13 +13,11 @@ exports.exportTasksById = exports.startAndConfirm = exports.confirm = exports.st
|
|
|
13
13
|
/**
|
|
14
14
|
* 予約取消取引サービス
|
|
15
15
|
*/
|
|
16
|
-
const createDebug = require("debug");
|
|
17
16
|
const moment = require("moment");
|
|
18
17
|
const mongoose = require("mongoose");
|
|
19
18
|
const factory = require("../../factory");
|
|
20
19
|
const settings_1 = require("../../settings");
|
|
21
20
|
const factory_1 = require("./cancelReservation/factory");
|
|
22
|
-
const debug = createDebug('chevre-domain:service');
|
|
23
21
|
function validateStartParams(params) {
|
|
24
22
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
25
23
|
var _a, _b;
|
|
@@ -235,9 +233,7 @@ function exportTasksById(params) {
|
|
|
235
233
|
default:
|
|
236
234
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
237
235
|
}
|
|
238
|
-
|
|
239
|
-
return repos.task.saveMany(taskAttributes);
|
|
240
|
-
// return Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
|
|
236
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
241
237
|
});
|
|
242
238
|
}
|
|
243
239
|
exports.exportTasksById = exportTasksById;
|
|
@@ -430,7 +430,7 @@ function exportTasksById(params) {
|
|
|
430
430
|
default:
|
|
431
431
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
432
432
|
}
|
|
433
|
-
return repos.task.saveMany(taskAttributes);
|
|
433
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
436
|
exports.exportTasksById = exportTasksById;
|
|
@@ -281,7 +281,7 @@ function processAuthorizeMovieTicket(params, transaction, paymentServiceId, useC
|
|
|
281
281
|
}
|
|
282
282
|
function saveAuthorizeResult(params) {
|
|
283
283
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
284
|
-
return repos.assetTransaction.
|
|
284
|
+
return repos.assetTransaction.findByIdAndUpdateInProgress(params);
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
287
|
/**
|
|
@@ -470,7 +470,7 @@ function exportTasksById(params) {
|
|
|
470
470
|
default:
|
|
471
471
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
472
472
|
}
|
|
473
|
-
return repos.task.saveMany(taskAttributes);
|
|
473
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
474
474
|
});
|
|
475
475
|
}
|
|
476
476
|
exports.exportTasksById = exportTasksById;
|
|
@@ -218,7 +218,7 @@ function exportTasksById(params) {
|
|
|
218
218
|
default:
|
|
219
219
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
220
220
|
}
|
|
221
|
-
return repos.task.saveMany(taskAttributes);
|
|
221
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
224
|
exports.exportTasksById = exportTasksById;
|
|
@@ -301,8 +301,7 @@ function exportTasksById(params) {
|
|
|
301
301
|
default:
|
|
302
302
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
303
303
|
}
|
|
304
|
-
return repos.task.saveMany(taskAttributes);
|
|
305
|
-
// return Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
|
|
304
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
306
305
|
});
|
|
307
306
|
}
|
|
308
307
|
exports.exportTasksById = exportTasksById;
|
|
@@ -2,7 +2,6 @@ import * as factory from '../../factory';
|
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
4
4
|
import { IMinimizedIndividualEvent, MongoRepository as EventRepo } from '../../repo/event';
|
|
5
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../repo/itemAvailability/screeningEvent';
|
|
6
5
|
import { MongoRepository as OfferRepo } from '../../repo/offer';
|
|
7
6
|
import { MongoRepository as OfferCatalogRepo } from '../../repo/offerCatalog';
|
|
8
7
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
@@ -12,9 +11,10 @@ import { MongoRepository as ProductRepo } from '../../repo/product';
|
|
|
12
11
|
import { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
13
12
|
import { RedisRepository as OfferRateLimitRepo } from '../../repo/rateLimit/offer';
|
|
14
13
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
14
|
+
import { StockHolderRepository as StockHolderRepo } from '../../repo/stockHolder';
|
|
15
15
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
16
16
|
export interface IStartOperationRepos {
|
|
17
|
-
|
|
17
|
+
stockHolder: StockHolderRepo;
|
|
18
18
|
event: EventRepo;
|
|
19
19
|
offer: OfferRepo;
|
|
20
20
|
offerCatalog: OfferCatalogRepo;
|
|
@@ -29,7 +29,7 @@ export interface IStartOperationRepos {
|
|
|
29
29
|
}
|
|
30
30
|
export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
31
31
|
export interface IAddReservationsOperationRepos {
|
|
32
|
-
|
|
32
|
+
stockHolder: StockHolderRepo;
|
|
33
33
|
event: EventRepo;
|
|
34
34
|
offer: OfferRepo;
|
|
35
35
|
offerCatalog: OfferCatalogRepo;
|
|
@@ -44,7 +44,7 @@ export interface IAddReservationsOperationRepos {
|
|
|
44
44
|
export type IAddReservationsOperation<T> = (repos: IAddReservationsOperationRepos) => Promise<T>;
|
|
45
45
|
export type ICancelOperation<T> = (repos: {
|
|
46
46
|
action: ActionRepo;
|
|
47
|
-
|
|
47
|
+
stockHolder: StockHolderRepo;
|
|
48
48
|
offerRateLimit: OfferRateLimitRepo;
|
|
49
49
|
reservation: ReservationRepo;
|
|
50
50
|
task: TaskRepo;
|
|
@@ -209,7 +209,7 @@ function searchEventSeatOffers(params) {
|
|
|
209
209
|
$projection: params.$projection
|
|
210
210
|
});
|
|
211
211
|
if (seats.length > 0) {
|
|
212
|
-
const availabilities = yield repos.
|
|
212
|
+
const availabilities = yield repos.stockHolder.searchHolders({
|
|
213
213
|
eventId: params.event.id,
|
|
214
214
|
startDate: moment(params.event.startDate)
|
|
215
215
|
.toDate(),
|
|
@@ -225,7 +225,10 @@ function searchEventSeatOffers(params) {
|
|
|
225
225
|
return OfferService.addOffers2Seat({
|
|
226
226
|
seat,
|
|
227
227
|
// unavailableOffers: [],
|
|
228
|
-
availability: availabilities[index].availability,
|
|
228
|
+
// availability: availabilities[index].availability,
|
|
229
|
+
availability: (typeof availabilities[index] === 'string')
|
|
230
|
+
? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
|
|
231
|
+
: factory.itemAvailability.InStock,
|
|
229
232
|
priceSpecs
|
|
230
233
|
});
|
|
231
234
|
});
|
|
@@ -638,7 +641,7 @@ function processLockSeats(params) {
|
|
|
638
641
|
const holder = params.transaction.id;
|
|
639
642
|
const maximumAttendeeCapacity4event = (_a = params.event.location) === null || _a === void 0 ? void 0 : _a.maximumAttendeeCapacity;
|
|
640
643
|
if (typeof maximumAttendeeCapacity4event === 'number') {
|
|
641
|
-
yield repos.
|
|
644
|
+
yield repos.stockHolder.lockIfNotLimitExceeded({
|
|
642
645
|
eventId: params.event.id,
|
|
643
646
|
startDate: moment(params.event.startDate)
|
|
644
647
|
.toDate(),
|
|
@@ -648,7 +651,7 @@ function processLockSeats(params) {
|
|
|
648
651
|
}, maximumAttendeeCapacity4event);
|
|
649
652
|
}
|
|
650
653
|
else {
|
|
651
|
-
yield repos.
|
|
654
|
+
yield repos.stockHolder.lock({
|
|
652
655
|
eventId: params.event.id,
|
|
653
656
|
startDate: moment(params.event.startDate)
|
|
654
657
|
.toDate(),
|
|
@@ -857,7 +860,7 @@ function exportTasksById(params) {
|
|
|
857
860
|
default:
|
|
858
861
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
859
862
|
}
|
|
860
|
-
return repos.task.saveMany(taskAttributes);
|
|
863
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
861
864
|
});
|
|
862
865
|
}
|
|
863
866
|
exports.exportTasksById = exportTasksById;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as factory from '../factory';
|
|
5
5
|
import { MongoRepository as AssetTransactionRepo } from '../repo/assetTransaction';
|
|
6
|
-
import { MongoRepository as ProjectRepo } from '../repo/project';
|
|
7
6
|
import { MongoRepository as TaskRepo } from '../repo/task';
|
|
8
7
|
import * as CancelReservationTransactionService from './assetTransaction/cancelReservation';
|
|
9
8
|
import * as MoneyTransferTransactionService from './assetTransaction/moneyTransfer';
|
|
@@ -30,7 +29,6 @@ export declare function exportTasks<T extends factory.assetTransactionType>(para
|
|
|
30
29
|
$in: T[];
|
|
31
30
|
};
|
|
32
31
|
}): (repos: {
|
|
33
|
-
project: ProjectRepo;
|
|
34
32
|
task: TaskRepo;
|
|
35
33
|
assetTransaction: AssetTransactionRepo;
|
|
36
34
|
}) => Promise<{
|
|
@@ -32,7 +32,6 @@ exports.reserve = ReserveTransactionService;
|
|
|
32
32
|
function exportTasks(params) {
|
|
33
33
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const transaction = yield repos.assetTransaction.startExportTasks({
|
|
35
|
-
// project: params.project,
|
|
36
35
|
typeOf: params.typeOf,
|
|
37
36
|
status: params.status
|
|
38
37
|
});
|
|
@@ -2,7 +2,6 @@ import * as factory from '../../../factory';
|
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
4
|
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
5
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../../repo/itemAvailability/screeningEvent';
|
|
6
5
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
7
6
|
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
8
7
|
import { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
@@ -11,6 +10,7 @@ import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
|
11
10
|
import { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
12
11
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
13
12
|
import { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
13
|
+
import { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
14
14
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
15
15
|
import { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
16
16
|
import { RedisRepository as TransactionNumberRepo } from '../../../repo/transactionNumber';
|
|
@@ -19,7 +19,7 @@ interface IAuthorizeRepos {
|
|
|
19
19
|
action: ActionRepo;
|
|
20
20
|
assetTransaction: AssetTransactionRepo;
|
|
21
21
|
event: EventRepo;
|
|
22
|
-
|
|
22
|
+
stockHolder: StockHolderRepo;
|
|
23
23
|
offer: OfferRepo;
|
|
24
24
|
offerCatalog: OfferCatalogRepo;
|
|
25
25
|
offerRateLimit: OfferRateLimitRepo;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../../repo/itemAvailability/screeningEvent';
|
|
5
4
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
6
5
|
import { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
6
|
+
import { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
8
8
|
import { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
9
9
|
interface ICancelRepos {
|
|
10
10
|
action: ActionRepo;
|
|
11
11
|
assetTransaction: AssetTransactionRepo;
|
|
12
|
-
|
|
12
|
+
stockHolder: StockHolderRepo;
|
|
13
13
|
offerRateLimit: OfferRateLimitRepo;
|
|
14
14
|
reservation: ReservationRepo;
|
|
15
15
|
task: TaskRepo;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../../repo/itemAvailability/screeningEvent';
|
|
5
4
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
6
5
|
import { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
6
|
+
import { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
8
8
|
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
9
9
|
interface IVoidTransactionRepos {
|
|
10
10
|
action: ActionRepo;
|
|
11
11
|
assetTransaction: AssetTransactionRepo;
|
|
12
|
-
|
|
12
|
+
stockHolder: StockHolderRepo;
|
|
13
13
|
offerRateLimit: OfferRateLimitRepo;
|
|
14
14
|
reservation: ReservationRepo;
|
|
15
15
|
task: TaskRepo;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MongoRepository as EventRepo } from '../repo/event';
|
|
2
|
-
import { RedisRepository as EventAvailabilityRepo } from '../repo/itemAvailability/screeningEvent';
|
|
3
2
|
import { MongoRepository as PlaceRepo } from '../repo/place';
|
|
4
3
|
import { MongoRepository as PriceSpecificationRepo } from '../repo/priceSpecification';
|
|
5
4
|
import { MongoRepository as ProjectRepo } from '../repo/project';
|
|
5
|
+
import { StockHolderRepository as StockHolderRepo } from '../repo/stockHolder';
|
|
6
6
|
import { MongoRepository as TaskRepo } from '../repo/task';
|
|
7
7
|
import * as factory from '../factory';
|
|
8
8
|
import * as EventOfferService from './offer/event';
|
|
@@ -44,7 +44,7 @@ export declare function searchEventSeatOffersWithPaging(params: {
|
|
|
44
44
|
}): (repos: {
|
|
45
45
|
event: EventRepo;
|
|
46
46
|
priceSpecification: PriceSpecificationRepo;
|
|
47
|
-
|
|
47
|
+
stockHolder: StockHolderRepo;
|
|
48
48
|
place: PlaceRepo;
|
|
49
49
|
}) => Promise<factory.place.seat.IPlaceWithOffer[]>;
|
|
50
50
|
interface IChangedEvent {
|
|
@@ -88,7 +88,7 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
88
88
|
}
|
|
89
89
|
} }));
|
|
90
90
|
if (seats.length > 0) {
|
|
91
|
-
const availabilities = yield repos.
|
|
91
|
+
const availabilities = yield repos.stockHolder.searchHolders({
|
|
92
92
|
eventId: params.event.id,
|
|
93
93
|
startDate: moment(event.startDate)
|
|
94
94
|
.toDate(),
|
|
@@ -104,7 +104,10 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
104
104
|
return addOffers2Seat({
|
|
105
105
|
seat,
|
|
106
106
|
// unavailableOffers: [],
|
|
107
|
-
availability: availabilities[index].availability,
|
|
107
|
+
// availability: availabilities[index].availability,
|
|
108
|
+
availability: (typeof availabilities[index] === 'string')
|
|
109
|
+
? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
|
|
110
|
+
: factory.itemAvailability.InStock,
|
|
108
111
|
priceSpecs
|
|
109
112
|
});
|
|
110
113
|
});
|
|
@@ -204,10 +204,6 @@ function onReturn(returnActionAttributes) {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
// タスク保管
|
|
207
|
-
|
|
208
|
-
yield repos.task.saveMany(taskAttributes);
|
|
209
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
210
|
-
// return repos.task.save(taskAttribute);
|
|
211
|
-
// }));
|
|
207
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
212
208
|
});
|
|
213
209
|
}
|
|
@@ -194,7 +194,7 @@ function publishPaymentUrl(params) {
|
|
|
194
194
|
paymentUrl: result.paymentUrl,
|
|
195
195
|
issuedThrough: { id: (typeof startParams.object.id === 'string') ? startParams.object.id : '' }
|
|
196
196
|
};
|
|
197
|
-
yield repos.transaction.
|
|
197
|
+
yield repos.transaction.findByIdAndUpdateInProgress({
|
|
198
198
|
id: transaction.id,
|
|
199
199
|
update: { $set: { 'object.paymentMethods': paymentMethodByPaymentUrl } }
|
|
200
200
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
4
|
-
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../repo/itemAvailability/screeningEvent';
|
|
5
4
|
import { RedisRepository as OfferRateLimitRepo } from '../../repo/rateLimit/offer';
|
|
6
5
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
6
|
+
import { StockHolderRepository as StockHolderRepo } from '../../repo/stockHolder';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
8
8
|
type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
|
|
9
9
|
/**
|
|
@@ -12,7 +12,7 @@ type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservat
|
|
|
12
12
|
declare function cancelPendingReservation(actionAttributesList: factory.action.cancel.reservation.IAttributes[]): (repos: {
|
|
13
13
|
action: ActionRepo;
|
|
14
14
|
assetTransaction: AssetTransactionRepo;
|
|
15
|
-
|
|
15
|
+
stockHolder: StockHolderRepo;
|
|
16
16
|
offerRateLimit: OfferRateLimitRepo;
|
|
17
17
|
reservation: ReservationRepo;
|
|
18
18
|
task: TaskRepo;
|
|
@@ -22,7 +22,7 @@ declare function cancelPendingReservation(actionAttributesList: factory.action.c
|
|
|
22
22
|
*/
|
|
23
23
|
declare function cancelReservation(actionAttributesList: factory.action.cancel.reservation.IAttributes[]): (repos: {
|
|
24
24
|
action: ActionRepo;
|
|
25
|
-
|
|
25
|
+
stockHolder: StockHolderRepo;
|
|
26
26
|
offerRateLimit: OfferRateLimitRepo;
|
|
27
27
|
reservation: ReservationRepo;
|
|
28
28
|
task: TaskRepo;
|
|
@@ -344,9 +344,9 @@ function processUnlockSeat(params) {
|
|
|
344
344
|
seatSection: ''
|
|
345
345
|
}
|
|
346
346
|
};
|
|
347
|
-
let holder = yield repos.
|
|
347
|
+
let holder = yield repos.stockHolder.getHolder(lockKey);
|
|
348
348
|
if (holder === params.expectedHolder) {
|
|
349
|
-
yield repos.
|
|
349
|
+
yield repos.stockHolder.unlock(lockKey);
|
|
350
350
|
}
|
|
351
351
|
// 予約取引がまだ座席を保持していれば座席ロック解除
|
|
352
352
|
const ticketedSeat = reservation.reservedTicket.ticketedSeat;
|
|
@@ -359,9 +359,9 @@ function processUnlockSeat(params) {
|
|
|
359
359
|
seatSection: ticketedSeat.seatSection
|
|
360
360
|
}
|
|
361
361
|
};
|
|
362
|
-
holder = yield repos.
|
|
362
|
+
holder = yield repos.stockHolder.getHolder(lockKey);
|
|
363
363
|
if (holder === params.expectedHolder) {
|
|
364
|
-
yield repos.
|
|
364
|
+
yield repos.stockHolder.unlock(lockKey);
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
// subReservationがあれば、そちらも解除(順不同)
|
|
@@ -380,9 +380,9 @@ function processUnlockSeat(params) {
|
|
|
380
380
|
seatSection: seatSection4sub
|
|
381
381
|
}
|
|
382
382
|
};
|
|
383
|
-
const holder4sub = yield repos.
|
|
383
|
+
const holder4sub = yield repos.stockHolder.getHolder(lockKey4sub);
|
|
384
384
|
if (holder4sub === params.expectedHolder) {
|
|
385
|
-
yield repos.
|
|
385
|
+
yield repos.stockHolder.unlock(lockKey4sub);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
})));
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const event_1 = require("../../repo/event");
|
|
15
|
-
const screeningEvent_1 = require("../../repo/itemAvailability/screeningEvent");
|
|
16
15
|
const offer_1 = require("../../repo/offer");
|
|
17
16
|
const offerCatalog_1 = require("../../repo/offerCatalog");
|
|
18
17
|
const place_1 = require("../../repo/place");
|
|
@@ -20,6 +19,7 @@ const product_1 = require("../../repo/product");
|
|
|
20
19
|
const project_1 = require("../../repo/project");
|
|
21
20
|
const offer_2 = require("../../repo/rateLimit/offer");
|
|
22
21
|
const reservation_1 = require("../../repo/reservation");
|
|
22
|
+
const stockHolder_1 = require("../../repo/stockHolder");
|
|
23
23
|
const task_1 = require("../../repo/task");
|
|
24
24
|
const AggregationService = require("../aggregation");
|
|
25
25
|
/**
|
|
@@ -32,7 +32,7 @@ function call(data) {
|
|
|
32
32
|
}
|
|
33
33
|
yield AggregationService.event.aggregateScreeningEvent(data)({
|
|
34
34
|
event: new event_1.MongoRepository(settings.connection),
|
|
35
|
-
|
|
35
|
+
stockHolder: new stockHolder_1.StockHolderRepository(settings.redisClient),
|
|
36
36
|
offer: new offer_1.MongoRepository(settings.connection),
|
|
37
37
|
offerCatalog: new offerCatalog_1.MongoRepository(settings.connection),
|
|
38
38
|
offerRateLimit: new offer_2.RedisRepository(settings.redisClient),
|
|
@@ -13,9 +13,9 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
-
const screeningEvent_1 = require("../../repo/itemAvailability/screeningEvent");
|
|
17
16
|
const offer_1 = require("../../repo/rateLimit/offer");
|
|
18
17
|
const reservation_1 = require("../../repo/reservation");
|
|
18
|
+
const stockHolder_1 = require("../../repo/stockHolder");
|
|
19
19
|
const task_1 = require("../../repo/task");
|
|
20
20
|
const ReserveService = require("../reserve");
|
|
21
21
|
/**
|
|
@@ -30,12 +30,12 @@ function call(data) {
|
|
|
30
30
|
const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
31
31
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
32
32
|
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
33
|
-
const
|
|
33
|
+
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
|
|
34
34
|
const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
|
|
35
35
|
yield ReserveService.cancelPendingReservation(data.actionAttributes)({
|
|
36
36
|
action: actionRepo,
|
|
37
37
|
assetTransaction: assetTransactionRepo,
|
|
38
|
-
|
|
38
|
+
stockHolder: stockHolderRepo,
|
|
39
39
|
offerRateLimit: offerRateLimitRepo,
|
|
40
40
|
reservation: reservationRepo,
|
|
41
41
|
task: taskRepo
|
|
@@ -13,9 +13,9 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
-
const screeningEvent_1 = require("../../repo/itemAvailability/screeningEvent");
|
|
17
16
|
const offer_1 = require("../../repo/rateLimit/offer");
|
|
18
17
|
const reservation_1 = require("../../repo/reservation");
|
|
18
|
+
const stockHolder_1 = require("../../repo/stockHolder");
|
|
19
19
|
const task_1 = require("../../repo/task");
|
|
20
20
|
const ReserveService = require("../reserve");
|
|
21
21
|
/**
|
|
@@ -30,7 +30,7 @@ function call(data) {
|
|
|
30
30
|
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
31
31
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
32
32
|
const transactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
33
|
-
const
|
|
33
|
+
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
|
|
34
34
|
const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
|
|
35
35
|
yield ReserveService.cancelReservation(data.actionAttributes)({
|
|
36
36
|
action: actionRepo,
|
|
@@ -38,7 +38,7 @@ function call(data) {
|
|
|
38
38
|
task: taskRepo,
|
|
39
39
|
assetTransaction: transactionRepo,
|
|
40
40
|
offerRateLimit: offerRateLimitRepo,
|
|
41
|
-
|
|
41
|
+
stockHolder: stockHolderRepo
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
}
|
|
@@ -13,9 +13,9 @@ exports.call = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
-
const screeningEvent_1 = require("../../repo/itemAvailability/screeningEvent");
|
|
17
16
|
const offer_1 = require("../../repo/rateLimit/offer");
|
|
18
17
|
const reservation_1 = require("../../repo/reservation");
|
|
18
|
+
const stockHolder_1 = require("../../repo/stockHolder");
|
|
19
19
|
const task_1 = require("../../repo/task");
|
|
20
20
|
const EventOfferService = require("../offer/event");
|
|
21
21
|
/**
|
|
@@ -28,14 +28,14 @@ function call(data) {
|
|
|
28
28
|
}
|
|
29
29
|
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
30
30
|
const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
31
|
-
const
|
|
31
|
+
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
|
|
32
32
|
const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
|
|
33
33
|
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
34
34
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
35
35
|
yield EventOfferService.voidTransaction(data)({
|
|
36
36
|
action: actionRepo,
|
|
37
37
|
assetTransaction: assetTransactionRepo,
|
|
38
|
-
|
|
38
|
+
stockHolder: stockHolderRepo,
|
|
39
39
|
offerRateLimit: offerRateLimitRepo,
|
|
40
40
|
reservation: reservationRepo,
|
|
41
41
|
task: taskRepo
|
|
@@ -16,11 +16,20 @@ export type TaskOperation<T> = (repos: {
|
|
|
16
16
|
task: TaskRepo;
|
|
17
17
|
}) => Promise<T>;
|
|
18
18
|
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
19
|
+
export declare function executeById(params: {
|
|
20
|
+
id: string;
|
|
21
|
+
executor: {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
}): IOperation<void>;
|
|
19
25
|
/**
|
|
20
26
|
* タスク名でタスクをひとつ実行する
|
|
21
27
|
*/
|
|
22
28
|
export declare function executeByName<T extends factory.taskName>(params: {
|
|
23
29
|
name: T;
|
|
30
|
+
executor: {
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
24
33
|
}): IOperation<void>;
|
|
25
34
|
/**
|
|
26
35
|
* タスクを実行する
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.notifyAbortedTasks = exports.abort = exports.retry = exports.execute = exports.executeByName = void 0;
|
|
12
|
+
exports.notifyAbortedTasks = exports.abort = exports.retry = exports.execute = exports.executeByName = exports.executeById = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* タスクサービス
|
|
15
15
|
*/
|
|
@@ -20,6 +20,27 @@ const NotificationService = require("./notification");
|
|
|
20
20
|
const factory_1 = require("./notification/factory");
|
|
21
21
|
const settings_1 = require("../settings");
|
|
22
22
|
const debug = createDebug('chevre-domain:service:task');
|
|
23
|
+
function executeById(params) {
|
|
24
|
+
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
26
|
+
// 未実行のタスクを取得
|
|
27
|
+
// tslint:disable-next-line:no-null-keyword
|
|
28
|
+
let task = null;
|
|
29
|
+
try {
|
|
30
|
+
task = yield taskRepo.executeById({ id: params.id, executor: params.executor });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
34
|
+
/* istanbul ignore next */
|
|
35
|
+
debug('service.task.executeById error:', error);
|
|
36
|
+
}
|
|
37
|
+
// タスクがなければ終了
|
|
38
|
+
if (task !== null) {
|
|
39
|
+
yield execute(task)(settings);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
exports.executeById = executeById;
|
|
23
44
|
/**
|
|
24
45
|
* タスク名でタスクをひとつ実行する
|
|
25
46
|
*/
|
|
@@ -576,9 +576,7 @@ function exportTasksById(params) {
|
|
|
576
576
|
transaction,
|
|
577
577
|
runsAt: taskRunsAt
|
|
578
578
|
});
|
|
579
|
-
|
|
580
|
-
yield repos.task.saveMany(taskAttributes);
|
|
581
|
-
// await Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
|
|
579
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
582
580
|
});
|
|
583
581
|
}
|
|
584
582
|
exports.exportTasksById = exportTasksById;
|
|
@@ -36,11 +36,7 @@ function exportTasksById(params) {
|
|
|
36
36
|
transaction,
|
|
37
37
|
runsAt: taskRunsAt
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
yield repos.task.saveMany(taskAttributes);
|
|
41
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
42
|
-
// await repos.task.save(taskAttribute);
|
|
43
|
-
// }));
|
|
39
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
44
40
|
});
|
|
45
41
|
}
|
|
46
42
|
exports.exportTasksById = exportTasksById;
|