Merged PR 818: function修正
## 概要 [Task3879: function修正](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3879) - 行番号をExcelの表記通りとなるように修正 - 途中から始められるようにforループを修正 ## レビューポイント - 共有 ## UIの変更 - Before/Afterのスクショなど - スクショ置き場 ## クエリの変更 - Repositoryを変更し、クエリが変更された場合は変更内容を確認する - Before/Afterのクエリ - クエリ置き場 ## 動作確認状況 - ローカルで確認、develop環境で確認など - 行った修正がデグレを発生させていないことを確認できるか - 具体的にどのような確認をしたか - どのケースに対してどのような手段でデグレがないことを担保しているか ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
85edd2296e
commit
2e6b7c8ab5
@ -389,7 +389,7 @@ export const selectImportFileName = (state: RootState) =>
|
|||||||
export const selectImportValidationErrors = (state: RootState) => {
|
export const selectImportValidationErrors = (state: RootState) => {
|
||||||
const csvUsers = state.user.apps.importUsers;
|
const csvUsers = state.user.apps.importUsers;
|
||||||
|
|
||||||
let rowNumber = 0;
|
let rowNumber = 1;
|
||||||
const invalidInput: number[] = [];
|
const invalidInput: number[] = [];
|
||||||
|
|
||||||
const duplicatedEmailsMap = new Map<string, number>();
|
const duplicatedEmailsMap = new Map<string, number>();
|
||||||
|
|||||||
@ -335,3 +335,5 @@ export const RoleNumberMap: Record<number, string> = {
|
|||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const SYSTEM_IMPORT_USERS = "import-users";
|
export const SYSTEM_IMPORT_USERS = "import-users";
|
||||||
|
|
||||||
|
export const ROW_START_INDEX = 2;
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
IMPORT_USERS_STAGE_FILE_NAME,
|
IMPORT_USERS_STAGE_FILE_NAME,
|
||||||
IMPORT_USERS_STAGES,
|
IMPORT_USERS_STAGES,
|
||||||
RoleNumberMap,
|
RoleNumberMap,
|
||||||
|
ROW_START_INDEX,
|
||||||
SYSTEM_IMPORT_USERS,
|
SYSTEM_IMPORT_USERS,
|
||||||
TIERS,
|
TIERS,
|
||||||
} from "../constants";
|
} from "../constants";
|
||||||
@ -47,7 +48,7 @@ export async function importUsersProcessing(
|
|||||||
if (targetFileName === undefined) {
|
if (targetFileName === undefined) {
|
||||||
throw new Error("targetFileName is undefined");
|
throw new Error("targetFileName is undefined");
|
||||||
}
|
}
|
||||||
let row = 1;
|
let row = ROW_START_INDEX;
|
||||||
|
|
||||||
// stage.jsonを取得(ダウンロード)して読み込む
|
// stage.jsonを取得(ダウンロード)して読み込む
|
||||||
let stageData = await blobstorageService.downloadFileData(
|
let stageData = await blobstorageService.downloadFileData(
|
||||||
@ -78,24 +79,29 @@ export async function importUsersProcessing(
|
|||||||
if (!isStageJson(stage)) {
|
if (!isStageJson(stage)) {
|
||||||
throw new Error("stage.json is invalid");
|
throw new Error("stage.json is invalid");
|
||||||
}
|
}
|
||||||
|
context.log(`start stage: ${JSON.stringify(stage)}`);
|
||||||
|
|
||||||
// 作業中のstage.jsonが存在する場合は、処理を再開する
|
// 作業中のstage.jsonが存在する場合は、処理を再開する
|
||||||
if (
|
if (
|
||||||
stage.state !== IMPORT_USERS_STAGES.CREATED &&
|
stage.state !== IMPORT_USERS_STAGES.CREATED &&
|
||||||
stage.state !== IMPORT_USERS_STAGES.DONE
|
stage.state !== IMPORT_USERS_STAGES.DONE
|
||||||
) {
|
) {
|
||||||
|
context.log(
|
||||||
|
`stage is pending. filename: ${stage.filename} row: ${stage.row}`
|
||||||
|
);
|
||||||
|
|
||||||
// stage.jsonが存在し、内部状態が処理中で、最終更新日時が10分以上前だった場合は処理中断とみなして途中から再開
|
// stage.jsonが存在し、内部状態が処理中で、最終更新日時が10分以上前だった場合は処理中断とみなして途中から再開
|
||||||
const nowUnixTime = getCurrentUnixTime();
|
const nowUnixTime = getCurrentUnixTime();
|
||||||
if (nowUnixTime - stage.update > 10 * 60) {
|
if (nowUnixTime - stage.update > 10 * 60) {
|
||||||
// stage.jsonの内容から処理対象のfilepathを特定する
|
// stage.jsonの内容から処理対象のfilepathを特定する
|
||||||
context.log(stage.filename);
|
context.log(`pending filename: ${stage.filename}`);
|
||||||
if (stage.filename === undefined) {
|
if (stage.filename === undefined) {
|
||||||
context.log("stage.filename is undefined");
|
context.log("stage.filename is undefined");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
targetFileName = stage.filename;
|
targetFileName = stage.filename;
|
||||||
// 処理開始行をstage.jsonを元に復元する
|
// 処理開始行をstage.jsonを元に復元する
|
||||||
row = stage.row ?? 1;
|
row = stage.row ?? ROW_START_INDEX;
|
||||||
} else {
|
} else {
|
||||||
// 内部状態が処理中であれば処理中断(処理が終わる前にTimerから再度起動されてしまったケース)
|
// 内部状態が処理中であれば処理中断(処理が終わる前にTimerから再度起動されてしまったケース)
|
||||||
context.log("stage is processing");
|
context.log("stage is processing");
|
||||||
@ -144,9 +150,9 @@ export async function importUsersProcessing(
|
|||||||
imports.user_role
|
imports.user_role
|
||||||
);
|
);
|
||||||
|
|
||||||
// 一括登録ユーザー一覧をループして、一括登録ユーザーを一括登録する
|
|
||||||
const errors: ErrorRow[] = [];
|
const errors: ErrorRow[] = [];
|
||||||
for (const user of imports.data) {
|
// 一括登録ユーザー一覧をループして、一括登録ユーザーを一括登録する(中断された場合は途中から再開するため、sliceで開始行を指定する)
|
||||||
|
for (const user of imports.data.slice(row - ROW_START_INDEX)) {
|
||||||
{
|
{
|
||||||
// stage.jsonを更新(ユーザー追加開始)
|
// stage.jsonを更新(ユーザー追加開始)
|
||||||
const updateSuccess = await blobstorageService.updateFile(
|
const updateSuccess = await blobstorageService.updateFile(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user