From 6dee72c50879e41a956b60368b49e5e7cf945754 Mon Sep 17 00:00:00 2001 From: Zachary Keeping Date: Thu, 19 Oct 2023 10:13:55 +1100 Subject: [PATCH 1/3] Show correct counts --- api/functions/queries.js | 8 ++++---- docker/utils.js | 4 ++-- .../buildlistcardcomponents/HistoryChart.svelte | 2 +- ui/src/components/misccomponents/Tabs.svelte | 2 +- .../scancomparecomponents/ScanCompareListItem.svelte | 8 ++++---- .../components/summaryitemcomponents/LinkSummary.svelte | 8 ++++---- ui/src/containers/ScanCompare.svelte | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/api/functions/queries.js b/api/functions/queries.js index 18302097..320fe4bf 100644 --- a/api/functions/queries.js +++ b/api/functions/queries.js @@ -279,7 +279,7 @@ exports.getAllScanSummaryFromUrl = (url, api) => for await (const item of iterator) { if (item[0]) { const existing = await getExistingBrokenLinkCount(item[0].runId); - item[0].totalUnique404Existing = existing; + item[0].totalUniqueBrokenLinksExisting = existing; } resolve(item); @@ -321,9 +321,9 @@ exports.compareScans = (api, url) => isHtmlErrorsUp: result[0].htmlErrors > result[1].htmlErrors, prevHtmlErrors: result[1].htmlErrors, currHtmlErrors: result[0].htmlErrors, - isBrokenLinksUp: result[0].totalUnique404 > result[1].totalUnique404, - prevBrokenLinks: result[1].totalUnique404, - currBrokenLinks: result[0].totalUnique404, + isBrokenLinksUp: result[0].uniqueBrokenLinks > result[1].uniqueBrokenLinks, + prevBrokenLinks: result[1].uniqueBrokenLinks, + currBrokenLinks: result[0].uniqueBrokenLinks, latestRunId: result[0].runId } resolve(isErrorUp) diff --git a/docker/utils.js b/docker/utils.js index be30c39e..24bcdb0f 100644 --- a/docker/utils.js +++ b/docker/utils.js @@ -29,7 +29,7 @@ exports.sendAlertEmail = async (email, emailConfig, scanSummary) => { from: 'foo@example.com', // sender address to: email, // list of receivers subject: `SSW CodeAuditor Scan Result - ${scanSummary.url}`, // Subject line - html: `

Hi there,

This is the result from SSW CodeAuditor scan on ${scanSummary.url} on ${fns.format(new Date(scanSummary.buildDate), 'dd MMM yyyy, hh:mm aaaa')}

⏳ Duration: ${scanSummary.scanDuration} seconds

🚨 Broken Links: ${scanSummary.totalUnique404} / ${scanSummary.totalScanned} Bad links

⚠️ HTML Warnings: ${scanSummary.htmlWarnings}

❌ HTML Errors: ${scanSummary.htmlErrors}

See https://codeauditor.com/build/${scanSummary.runId} for full scan result

<This is the automated alert email from SSW CodeAuditor>

`, + html: `

Hi there,

This is the result from SSW CodeAuditor scan on ${scanSummary.url} on ${fns.format(new Date(scanSummary.buildDate), 'dd MMM yyyy, hh:mm aaaa')}

⏳ Duration: ${scanSummary.scanDuration} seconds

🚨 Broken Links: ${scanSummary.uniqueBrokenLinks} / ${scanSummary.totalScanned} Bad links

⚠️ HTML Warnings: ${scanSummary.htmlWarnings}

❌ HTML Errors: ${scanSummary.htmlErrors}

See https://codeauditor.com/build/${scanSummary.runId} for full scan result

<This is the automated alert email from SSW CodeAuditor>

`, }); } @@ -418,7 +418,7 @@ exports.processBrokenLinks = ( const __getBadResults = (allUrls) => allUrls // Allow successful 2xx status code range (200-299) - .filter((url) => !(url["StatusCode"]?.startsWith('2') && url["StatusCode"]?.length === 3)) + .filter((url) => !((url["StatusCode"]?.startsWith('2') || url["StatusCode"]?.startsWith('3')) && url["StatusCode"]?.length === 3)) .map((x) => ({ src: x.Source || "", dst: x.Destination || "", diff --git a/ui/src/components/buildlistcardcomponents/HistoryChart.svelte b/ui/src/components/buildlistcardcomponents/HistoryChart.svelte index 3cba0590..0b1928fd 100644 --- a/ui/src/components/buildlistcardcomponents/HistoryChart.svelte +++ b/ui/src/components/buildlistcardcomponents/HistoryChart.svelte @@ -12,7 +12,7 @@ // Categorize and populate charts with data, title and color if (dataType === historyChartType.BadLinks) { chartTitle = historyChartType.BadLinks; - allDataToDisplay = value.map((i) => i.totalUnique404); + allDataToDisplay = value.map((i) => i.uniqueBrokenLinks); barColor = 'red' } else if (dataType === historyChartType.WarningCode) { chartTitle = historyChartType.WarningCode; diff --git a/ui/src/components/misccomponents/Tabs.svelte b/ui/src/components/misccomponents/Tabs.svelte index a9baad88..8f3adaba 100644 --- a/ui/src/components/misccomponents/Tabs.svelte +++ b/ui/src/components/misccomponents/Tabs.svelte @@ -48,7 +48,7 @@
  • - Links{build.summary ? ` (${build.summary.totalUnique404})` : ''} + Links{build.summary ? ` (${build.summary.uniqueBrokenLinks})` : ''}
  • diff --git a/ui/src/components/scancomparecomponents/ScanCompareListItem.svelte b/ui/src/components/scancomparecomponents/ScanCompareListItem.svelte index 11fdd120..0ba316ad 100644 --- a/ui/src/components/scancomparecomponents/ScanCompareListItem.svelte +++ b/ui/src/components/scancomparecomponents/ScanCompareListItem.svelte @@ -12,11 +12,11 @@
    0} - class:textgrey={value.totalUnique404 === 0} + class:textred={value.uniqueBrokenLinks > 0} + class:textgrey={value.uniqueBrokenLinks === 0} > - {value.totalUnique404} + {value.uniqueBrokenLinks}
    {#if Object.keys(comparisonDifferences).length > 0} @@ -24,7 +24,7 @@ {numberWithCommas(Math.abs(comparisonDifferences.brokenLinksDifference))} {/if}
    -

    Broken Links {value.totalUnique404Existing !== undefined ? `(${value.totalUnique404Existing || 0} Existing)` : ''}

    +

    Broken Links {value.totalUniqueBrokenLinksExisting !== undefined ? `(${value.totalUniqueBrokenLinksExisting || 0} Existing)` : ''}

    diff --git a/ui/src/components/summaryitemcomponents/LinkSummary.svelte b/ui/src/components/summaryitemcomponents/LinkSummary.svelte index 5c60448e..b03ff3f1 100644 --- a/ui/src/components/summaryitemcomponents/LinkSummary.svelte +++ b/ui/src/components/summaryitemcomponents/LinkSummary.svelte @@ -19,10 +19,10 @@ 0} - class:textgrey={value.totalUnique404 === 0}> - {value.totalUnique404} - {#if value.totalUnique404 === 0} + class:text-red-600={value.uniqueBrokenLinks > 0} + class:textgrey={value.uniqueBrokenLinks === 0}> + {value.uniqueBrokenLinks} + {#if value.uniqueBrokenLinks === 0} {/if} diff --git a/ui/src/containers/ScanCompare.svelte b/ui/src/containers/ScanCompare.svelte index d06bd4de..8c33df9b 100644 --- a/ui/src/containers/ScanCompare.svelte +++ b/ui/src/containers/ScanCompare.svelte @@ -36,7 +36,7 @@ if (allScans.length > 0 && selectedScan) { comparisonDifferences = { brokenLinksDifference: - allScans[0].totalUnique404 - selectedScan.totalUnique404, + allScans[0].uniqueBrokenLinks - selectedScan.uniqueBrokenLinks, codeWarningDifference: allScans[0].htmlWarnings - selectedScan.htmlWarnings, codeErrorDifference: allScans[0].htmlErrors - selectedScan.htmlErrors, From 7d5ed9f4873384161431c365352c78756e79d434 Mon Sep 17 00:00:00 2001 From: Zachary Keeping Date: Thu, 19 Oct 2023 10:17:51 +1100 Subject: [PATCH 2/3] Update text --- ui/src/components/summaryitemcomponents/LinkSummary.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/components/summaryitemcomponents/LinkSummary.svelte b/ui/src/components/summaryitemcomponents/LinkSummary.svelte index b03ff3f1..c3471151 100644 --- a/ui/src/components/summaryitemcomponents/LinkSummary.svelte +++ b/ui/src/components/summaryitemcomponents/LinkSummary.svelte @@ -15,7 +15,7 @@
    - 404 Errors + Broken Links Date: Thu, 19 Oct 2023 10:19:25 +1100 Subject: [PATCH 3/3] Show commas --- ui/src/components/summaryitemcomponents/LinkSummary.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/components/summaryitemcomponents/LinkSummary.svelte b/ui/src/components/summaryitemcomponents/LinkSummary.svelte index c3471151..ea628477 100644 --- a/ui/src/components/summaryitemcomponents/LinkSummary.svelte +++ b/ui/src/components/summaryitemcomponents/LinkSummary.svelte @@ -21,7 +21,7 @@ class="font-sans font-bold block lg:inline-block" class:text-red-600={value.uniqueBrokenLinks > 0} class:textgrey={value.uniqueBrokenLinks === 0}> - {value.uniqueBrokenLinks} + {numberWithCommas(value.uniqueBrokenLinks)} {#if value.uniqueBrokenLinks === 0} {/if}