Skip to content

Commit

Permalink
Merge pull request #717 from SSWConsulting/comparescans-error-handling
Browse files Browse the repository at this point in the history
Add null checks to compareScans function
  • Loading branch information
tombui99 authored Oct 20, 2023
2 parents b4b0658 + 6fb65df commit 786c639
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions api/functions/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,21 @@ exports.compareScans = (api, url) =>
for await (const item of entity) {
result.push(item);
}

const latestResult = result[0] || {};
const prevResult = result[1] || {};

let isErrorUp = {
isHtmlWarningsUp: result[0].htmlWarnings > result[1].htmlWarnings,
prevHtmlWarnings: result[1].htmlWarnings,
currHtmlWarnings: result[0].htmlWarnings,
isHtmlErrorsUp: result[0].htmlErrors > result[1].htmlErrors,
prevHtmlErrors: result[1].htmlErrors,
currHtmlErrors: result[0].htmlErrors,
isBrokenLinksUp: result[0].uniqueBrokenLinks > result[1].uniqueBrokenLinks,
prevBrokenLinks: result[1].uniqueBrokenLinks,
currBrokenLinks: result[0].uniqueBrokenLinks,
latestRunId: result[0].runId
isHtmlWarningsUp: latestResult.htmlWarnings > prevResult.htmlWarnings,
prevHtmlWarnings: prevResult.htmlWarnings || 0,
currHtmlWarnings: latestResult.htmlWarnings || 0,
isHtmlErrorsUp: latestResult.htmlErrors > prevResult.htmlErrors,
prevHtmlErrors: prevResult.htmlErrors || 0,
currHtmlErrors: latestResult.htmlErrors || 0,
isBrokenLinksUp: latestResult.uniqueBrokenLinks > prevResult.uniqueBrokenLinks,
prevBrokenLinks: prevResult.uniqueBrokenLinks || 0,
currBrokenLinks: latestResult.uniqueBrokenLinks || 0,
latestRunId: latestResult.runId
}
resolve(isErrorUp)
});

0 comments on commit 786c639

Please sign in to comment.