Skip to content

Commit

Permalink
Remove querying fileErrors in graphql api while fetching media import…
Browse files Browse the repository at this point in the history
… status as it's only required for v1
  • Loading branch information
aagam-shah committed Aug 8, 2024
1 parent 490ae44 commit 2b67f2d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
2 changes: 0 additions & 2 deletions src/graphqlTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,6 @@ export type AppEnvironmentMediaImportStatusChange = {
/** Media Import Failure details */
export type AppEnvironmentMediaImportStatusFailureDetails = {
__typename?: 'AppEnvironmentMediaImportStatusFailureDetails';
/** List of errors per file */
fileErrors?: Maybe< Array< Maybe< AppEnvironmentMediaImportStatusFailureDetailsFileErrors > > >;
/** URL to download the media import error log */
fileErrorsUrl?: Maybe< Scalars[ 'String' ][ 'output' ] >;
/** List of global errors per import */
Expand Down
37 changes: 4 additions & 33 deletions src/lib/media-import/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ const IMPORT_MEDIA_PROGRESS_QUERY = gql`
failureDetails {
previousStatus
globalErrors
fileErrors {
fileName
errors
}
fileErrorsUrl
}
}
Expand Down Expand Up @@ -351,22 +347,6 @@ Downloading errors details from ${ fileErrorsUrl }
}
}

async function printFailureDetails(
fileErrors: Maybe< AppEnvironmentMediaImportStatusFailureDetailsFileErrors >[],
results: AppEnvironmentMediaImportStatus
) {
progressTracker.suffix += `${ chalk.yellow(
`⚠️ ${ fileErrors.length } file import error(s) were found`
) }`;

if ( ( results.filesTotal ?? 0 ) - ( results.filesProcessed ?? 0 ) !== fileErrors.length ) {
progressTracker.suffix += `. ${ chalk.italic.yellow(
'File import errors report size threshold reached.'
) }`;
}
await exportFailureDetails( fileErrors );
}

try {
const results: AppEnvironmentMediaImportStatus = await getResults();
overallStatus = results.status ?? 'unknown';
Expand All @@ -379,19 +359,10 @@ Downloading errors details from ${ fileErrorsUrl }
await promptFailureDetailsDownload(
results.failureDetails.fileErrorsUrl as unknown as string
);
} else {
const fileErrors = results.failureDetails?.fileErrors ?? [];

if ( fileErrors.length > 0 ) {
// Errors were observed and are present in the dto
// Fall back to exporting errors to local file
await printFailureDetails( fileErrors, results );
} else if ( 'ABORTED' !== overallStatus ) {
// Errors are not present in the dto
// And file error details report link is not available
// do not print this message if the import was aborted
printFileErrorsReportLinkExpiredError( results );
}
} else if ( 'ABORTED' !== overallStatus ) {
// print report link expired if required
// do not print this message if the import was aborted
printFileErrorsReportLinkExpiredError( results );
}

// Print one final time
Expand Down

0 comments on commit 2b67f2d

Please sign in to comment.