Merged PR 715: 行ロック横展開4
## 概要 [Task3472: 行ロック横展開4](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3472) - 対象メソッド - user_groups - createTypistGroup - グループに含めるユーザー情報取得箇所でロック追加 - ユーザー削除と被ると、削除済みユーザーをユーザーグループに含めてしまう - updateTypistGroup - グループに含めるユーザー情報取得箇所でロック追加 - ユーザー削除と被ると、削除済みユーザーをユーザーグループに含めてしまう - グループの存在確認を行う箇所 - グループ削除と被ると、削除済みのグループにメンバーを割り当ててしまう - workflows - createtWorkflows - updatetWorkflow - インデックス追加 - user - role ## レビューポイント - インデックスの貼り忘れはないか - ロックの追加忘れはないか ## 共有資料 - https://ndstokyo.sharepoint.com/:f:/r/sites/Piranha/Shared%20Documents/General/OMDS/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88/Task3472?csf=1&web=1&e=jjb0QV ## 動作確認状況 - ローカルでロックされている箇所で待ちが発生していることを確認 ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
06b5249e5a
commit
4548b5e510
5
dictation_server/db/migrations/055-add_users_index.sql
Normal file
5
dictation_server/db/migrations/055-add_users_index.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- +migrate Up
|
||||
ALTER TABLE `users` ADD INDEX `idx_role` (role);
|
||||
|
||||
-- +migrate Down
|
||||
ALTER TABLE `users` DROP INDEX `idx_role`;
|
||||
@ -122,8 +122,8 @@ export class UserGroupsRepositoryService {
|
||||
role: USER_ROLES.TYPIST,
|
||||
email_verified: true,
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
if (userRecords.length !== typistIds.length) {
|
||||
throw new TypistIdInvalidError(
|
||||
@ -189,8 +189,8 @@ export class UserGroupsRepositoryService {
|
||||
role: USER_ROLES.TYPIST,
|
||||
email_verified: true,
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
if (userRecords.length !== typistIds.length) {
|
||||
throw new TypistIdInvalidError(
|
||||
@ -206,6 +206,7 @@ export class UserGroupsRepositoryService {
|
||||
id: typistGroupId,
|
||||
account_id: accountId,
|
||||
},
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
if (!typistGroup) {
|
||||
|
||||
@ -101,6 +101,7 @@ export class WorkflowsRepositoryService {
|
||||
const worktypes = await worktypeRepo.find({
|
||||
where: { account_id: accountId, id: worktypeId },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (worktypes.length === 0) {
|
||||
throw new WorktypeIdNotFoundError(
|
||||
@ -115,6 +116,7 @@ export class WorkflowsRepositoryService {
|
||||
const template = await templateRepo.findOne({
|
||||
where: { account_id: accountId, id: templateId },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (!template) {
|
||||
throw new TemplateFileNotExistError('template not found.');
|
||||
@ -132,6 +134,7 @@ export class WorkflowsRepositoryService {
|
||||
email_verified: true,
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (typistUsers.length !== typistIds.length) {
|
||||
throw new UserNotFoundError(
|
||||
@ -147,6 +150,7 @@ export class WorkflowsRepositoryService {
|
||||
const typistGroups = await userGroupRepo.find({
|
||||
where: { account_id: accountId, id: In(groupIds) },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (typistGroups.length !== groupIds.length) {
|
||||
throw new TypistGroupNotExistError(
|
||||
@ -164,6 +168,7 @@ export class WorkflowsRepositoryService {
|
||||
worktype_id: worktypeId !== undefined ? worktypeId : IsNull(),
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (workflow.length !== 0) {
|
||||
throw new AuthorIdAndWorktypeIdPairAlreadyExistsError(
|
||||
@ -264,6 +269,7 @@ export class WorkflowsRepositoryService {
|
||||
const targetWorkflow = await workflowRepo.findOne({
|
||||
where: { account_id: accountId, id: workflowId },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (!targetWorkflow) {
|
||||
throw new WorkflowNotFoundError(
|
||||
@ -277,6 +283,7 @@ export class WorkflowsRepositoryService {
|
||||
const worktypes = await worktypeRepo.find({
|
||||
where: { account_id: accountId, id: worktypeId },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (worktypes.length === 0) {
|
||||
throw new WorktypeIdNotFoundError(
|
||||
@ -291,6 +298,7 @@ export class WorkflowsRepositoryService {
|
||||
const template = await templateRepo.findOne({
|
||||
where: { account_id: accountId, id: templateId },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (!template) {
|
||||
throw new TemplateFileNotExistError(
|
||||
@ -402,6 +410,7 @@ export class WorkflowsRepositoryService {
|
||||
const workflow = await workflowRepo.findOne({
|
||||
where: { account_id: accountId, id: workflowId },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (!workflow) {
|
||||
throw new WorkflowNotFoundError(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user