このコミットが含まれているのは:
@@ -7,8 +7,12 @@ const hasSkipReason = (row: PostImportRow): boolean =>
|
||||
const hasValidationErrors = (row: PostImportRow): boolean =>
|
||||
Object.keys (row.validationErrors ?? { }).length > 0
|
||||
|
||||
const isRecoverableRow = (row: PostImportRow): boolean =>
|
||||
row.recoverable === true
|
||||
|
||||
const isRepairableImportStatus = (row: PostImportRow): boolean =>
|
||||
row.importStatus === 'failed' || row.importStatus === 'pending'
|
||||
isRecoverableRow (row)
|
||||
&& (row.importStatus === 'failed' || row.importStatus === 'pending')
|
||||
|
||||
const buildResetSnapshot = (row: PostImportRow) => ({
|
||||
url: row.url,
|
||||
@@ -63,7 +67,8 @@ export const resultSummaryCounts = (rows: PostImportRow[]) =>
|
||||
++counts.skipped
|
||||
return counts
|
||||
}
|
||||
if (row.importStatus === 'failed')
|
||||
if (row.importStatus === 'failed'
|
||||
|| (row.recoverable === true && row.importStatus === 'pending'))
|
||||
++counts.failed
|
||||
return counts
|
||||
},
|
||||
@@ -84,6 +89,32 @@ export const resultRowMessages = (row: PostImportRow): string[] =>
|
||||
...Object.values (row.importErrors ?? { }).flat ()])]
|
||||
|
||||
|
||||
export const resultRowWarnings = (row: PostImportRow): string[] =>
|
||||
[...new Set ([
|
||||
...Object.values (row.fieldWarnings ?? { }).flat (),
|
||||
...row.baseWarnings])]
|
||||
|
||||
|
||||
export const replaceImportRow = (
|
||||
rows: PostImportRow[],
|
||||
nextRow: PostImportRow,
|
||||
): PostImportRow[] =>
|
||||
rows.map (row => row.sourceRow === nextRow.sourceRow ? nextRow : row)
|
||||
|
||||
|
||||
export const mergeValidatedImportRow = (
|
||||
rows: PostImportRow[],
|
||||
validated: PostImportRow,
|
||||
): PostImportRow[] => {
|
||||
const current = rows.find (row => row.sourceRow === validated.sourceRow)
|
||||
if (current == null)
|
||||
return rows
|
||||
|
||||
const [merged] = mergeValidatedImportRows ([current], [validated])
|
||||
return merged == null ? rows : replaceImportRow (rows, merged)
|
||||
}
|
||||
|
||||
|
||||
export const mergeValidatedImportRows = (
|
||||
current: PostImportRow[],
|
||||
validated: PostImportRow[],
|
||||
@@ -150,6 +181,7 @@ export const mergeImportResults = (
|
||||
return {
|
||||
...row,
|
||||
importStatus: 'created',
|
||||
recoverable: undefined,
|
||||
skipReason: undefined,
|
||||
createdPostId: result.post.id,
|
||||
existingPostId: undefined,
|
||||
@@ -160,6 +192,7 @@ export const mergeImportResults = (
|
||||
return {
|
||||
...row,
|
||||
importStatus: 'skipped',
|
||||
recoverable: undefined,
|
||||
skipReason: 'existing',
|
||||
createdPostId: undefined,
|
||||
existingPostId: result.existingPostId,
|
||||
@@ -170,6 +203,7 @@ export const mergeImportResults = (
|
||||
return {
|
||||
...row,
|
||||
importStatus: 'failed',
|
||||
recoverable: result.recoverable === true ? true : undefined,
|
||||
skipReason: undefined,
|
||||
createdPostId: undefined,
|
||||
existingPostId: undefined,
|
||||
@@ -186,7 +220,9 @@ export const retryImportRow = (
|
||||
sourceRow: number,
|
||||
): PostImportRow[] =>
|
||||
rows.map (row =>
|
||||
row.sourceRow === sourceRow && row.importStatus === 'failed'
|
||||
row.sourceRow === sourceRow
|
||||
&& row.importStatus === 'failed'
|
||||
&& row.recoverable === true
|
||||
? { ...row, importStatus: 'pending', importErrors: undefined }
|
||||
: row)
|
||||
|
||||
|
||||
新しい課題から参照
ユーザをブロックする