Merged PR 357: [Sp16-1]カードライセンスのレコード作成がbulkinsertになっていない
## 概要 [Task2409: [Sp16-1]カードライセンスのレコード作成がbulkinsertになっていない](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2409) - 元PBI or タスクへのリンク(内容・目的などはそちらにあるはず) - 何をどう変更したか、追加したライブラリなど push→saveではなく、QueryBuilderを使用してバルクインサートを行うよう修正。 - このPull Requestでの対象/対象外 - 影響範囲(他の機能にも影響があるか) 既存のカードライセンス発行処理 既存のライセンス発行処理 ## レビューポイント - 特にレビューしてほしい箇所 - 軽微なものや自明なものは記載不要 - 修正範囲が大きい場合などに記載 - 全体的にや仕様を満たしているか等は本当に必要な時のみ記載 ## UIの変更 - Before/Afterのスクショなど - スクショ置き場 ## 動作確認状況 - ローカルで確認 既存ユニットテスト +ローカル環境でカードライセンステーブル、ライセンステーブルへのDB登録・更新処理が想定通りに行われることを確認 ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
15d7119306
commit
7be84e9bbc
@ -312,7 +312,7 @@ describe('DBテスト', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const service = module.get<LicensesService>(LicensesService);
|
const service = module.get<LicensesService>(LicensesService);
|
||||||
const issueCount = 1000;
|
const issueCount = 500;
|
||||||
await service.issueCardLicenseKeys(externalId, issueCount);
|
await service.issueCardLicenseKeys(externalId, issueCount);
|
||||||
const dbSelectResult = await selectCardLicensesCount(source);
|
const dbSelectResult = await selectCardLicensesCount(source);
|
||||||
expect(dbSelectResult.count).toEqual(issueCount);
|
expect(dbSelectResult.count).toEqual(issueCount);
|
||||||
|
|||||||
@ -103,8 +103,7 @@ export class LicensesRepositoryService {
|
|||||||
const cardLicenseIssueRepo =
|
const cardLicenseIssueRepo =
|
||||||
entityManager.getRepository(CardLicenseIssue);
|
entityManager.getRepository(CardLicenseIssue);
|
||||||
|
|
||||||
const licenses = [];
|
const licenses: License[] = [];
|
||||||
//TODO タスク 2409: カードライセンスのレコード作成がbulkinsertになっていない
|
|
||||||
// ライセンステーブルを作成する(BULK INSERT)
|
// ライセンステーブルを作成する(BULK INSERT)
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
const license = new License();
|
const license = new License();
|
||||||
@ -113,7 +112,12 @@ export class LicensesRepositoryService {
|
|||||||
license.type = LICENSE_TYPE.CARD;
|
license.type = LICENSE_TYPE.CARD;
|
||||||
licenses.push(license);
|
licenses.push(license);
|
||||||
}
|
}
|
||||||
const savedLicenses = await licensesRepo.save(licenses);
|
const savedLicenses = await licensesRepo
|
||||||
|
.createQueryBuilder()
|
||||||
|
.insert()
|
||||||
|
.into(License)
|
||||||
|
.values(licenses)
|
||||||
|
.execute();
|
||||||
|
|
||||||
// カードライセンス発行テーブルを作成する
|
// カードライセンス発行テーブルを作成する
|
||||||
const cardLicenseIssue = new CardLicenseIssue();
|
const cardLicenseIssue = new CardLicenseIssue();
|
||||||
@ -160,17 +164,21 @@ export class LicensesRepositoryService {
|
|||||||
isDuplicateKeysExist = false;
|
isDuplicateKeysExist = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cardLicenses = [];
|
const cardLicenses: CardLicense[] = [];
|
||||||
//TODO タスク 2409: カードライセンスのレコード作成がbulkinsertになっていない
|
|
||||||
// カードライセンステーブルを作成する(BULK INSERT)
|
// カードライセンステーブルを作成する(BULK INSERT)
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
const cardLicense = new CardLicense();
|
const cardLicense = new CardLicense();
|
||||||
cardLicense.license_id = savedLicenses[i].id; // Licenseテーブルの自動採番されたIDを挿入
|
cardLicense.license_id = savedLicenses.generatedMaps[i].id; // Licenseテーブルの自動採番されたIDを挿入
|
||||||
cardLicense.issue_id = savedCardLicensesIssue.id; // CardLicenseIssueテーブルの自動採番されたIDを挿入
|
cardLicense.issue_id = savedCardLicensesIssue.id; // CardLicenseIssueテーブルの自動採番されたIDを挿入
|
||||||
cardLicense.card_license_key = licenseKeys[i];
|
cardLicense.card_license_key = licenseKeys[i];
|
||||||
cardLicenses.push(cardLicense);
|
cardLicenses.push(cardLicense);
|
||||||
}
|
}
|
||||||
await cardLicenseRepo.save(cardLicenses);
|
await cardLicenseRepo
|
||||||
|
.createQueryBuilder()
|
||||||
|
.insert()
|
||||||
|
.into(CardLicense)
|
||||||
|
.values(cardLicenses)
|
||||||
|
.execute();
|
||||||
});
|
});
|
||||||
return licenseKeys;
|
return licenseKeys;
|
||||||
}
|
}
|
||||||
@ -367,7 +375,12 @@ export class LicensesRepositoryService {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
// ライセンステーブルを登録(注文元)
|
// ライセンステーブルを登録(注文元)
|
||||||
await licenseRepo.save(newLicenses);
|
await licenseRepo
|
||||||
|
.createQueryBuilder()
|
||||||
|
.insert()
|
||||||
|
.into(License)
|
||||||
|
.values(newLicenses)
|
||||||
|
.execute();
|
||||||
|
|
||||||
// 第一階層の場合はストックライセンスの概念が存在しないため、ストックライセンス変更処理は行わない
|
// 第一階層の場合はストックライセンスの概念が存在しないため、ストックライセンス変更処理は行わない
|
||||||
if (tier !== TIERS.TIER1) {
|
if (tier !== TIERS.TIER1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user