Skip to content

Commit

Permalink
Merge pull request #710 from SSWConsulting/bad-urls
Browse files Browse the repository at this point in the history
Show correct broken link counts
  • Loading branch information
tombui99 authored Oct 19, 2023
2 parents 2be31d5 + 172513d commit 2438d9a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions api/functions/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions docker/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports.sendAlertEmail = async (email, emailConfig, scanSummary) => {
from: '[email protected]', // sender address
to: email, // list of receivers
subject: `SSW CodeAuditor Scan Result - ${scanSummary.url}`, // Subject line
html: `<h2 style="color: red">Hi there,</h2><p>This is the result from SSW CodeAuditor scan on ${scanSummary.url} on ${fns.format(new Date(scanSummary.buildDate), 'dd MMM yyyy, hh:mm aaaa')}</p><p>⏳ Duration: ${scanSummary.scanDuration} seconds</p><p>🚨 Broken Links: ${scanSummary.totalUnique404} / ${scanSummary.totalScanned} Bad links</p><p>⚠️ HTML Warnings: ${scanSummary.htmlWarnings}</p><p>❌ HTML Errors: ${scanSummary.htmlErrors}</p><p>See https://codeauditor.com/build/${scanSummary.runId} for full scan result</p><p>&#60;This is the automated alert email from SSW CodeAuditor&#62;</p>`,
html: `<h2 style="color: red">Hi there,</h2><p>This is the result from SSW CodeAuditor scan on ${scanSummary.url} on ${fns.format(new Date(scanSummary.buildDate), 'dd MMM yyyy, hh:mm aaaa')}</p><p>⏳ Duration: ${scanSummary.scanDuration} seconds</p><p>🚨 Broken Links: ${scanSummary.uniqueBrokenLinks} / ${scanSummary.totalScanned} Bad links</p><p>⚠️ HTML Warnings: ${scanSummary.htmlWarnings}</p><p>❌ HTML Errors: ${scanSummary.htmlErrors}</p><p>See https://codeauditor.com/build/${scanSummary.runId} for full scan result</p><p>&#60;This is the automated alert email from SSW CodeAuditor&#62;</p>`,
});
}

Expand Down Expand Up @@ -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 || "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/misccomponents/Tabs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<li class="mr-1" class:-mb-px={displayMode === 'Links'}>
<span class={baseClass + (displayMode === 'Links' ? active : '')}>
<Navigate to={'/build/' + build.summary.runId}>
Links{build.summary ? ` (${build.summary.totalUnique404})` : ''}
Links{build.summary ? ` (${build.summary.uniqueBrokenLinks})` : ''}
</Navigate>
</span>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@

<div class="grid grid-cols-2 grid-rows-2 text-start font-sans font-bold my-4">
<div
class:textred={value.totalUnique404 > 0}
class:textgrey={value.totalUnique404 === 0}
class:textred={value.uniqueBrokenLinks > 0}
class:textgrey={value.uniqueBrokenLinks === 0}
>
<i class="fas fa-link-slash textred text-3xl"/>
<span class="text-4xl">{value.totalUnique404}</span>
<span class="text-4xl">{value.uniqueBrokenLinks}</span>
</div>
<div class="text-right my-auto">
{#if Object.keys(comparisonDifferences).length > 0}
<i class="textgrey fas {comparisonDifferences.brokenLinksDifference > 0 ? "fa-arrow-up" : comparisonDifferences.brokenLinksDifference === 0 ? "fa-arrow-right" : "fa-arrow-down"}"/>
<span class="textgrey">{numberWithCommas(Math.abs(comparisonDifferences.brokenLinksDifference))}</span>
{/if}
</div>
<h3 class="col-span-2 font-bold font-sans textgrey">Broken Links {value.totalUnique404Existing !== undefined ? `(${value.totalUnique404Existing || 0} Existing)` : ''}</h3>
<h3 class="col-span-2 font-bold font-sans textgrey">Broken Links {value.totalUniqueBrokenLinksExisting !== undefined ? `(${value.totalUniqueBrokenLinksExisting || 0} Existing)` : ''}</h3>
</div>

<div class="grid grid-cols-2 grid-rows-2 text-start font-sans font-bold my-4">
Expand Down
10 changes: 5 additions & 5 deletions ui/src/components/summaryitemcomponents/LinkSummary.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
<div class="col-span-1">
<span class="block whitespace-nowrap font-sans">
<i class="textred fas fa-link-slash"></i>
404 Errors
Broken Links
</span>
<span
class="font-sans font-bold block lg:inline-block"
class:text-red-600={value.totalUnique404 > 0}
class:textgrey={value.totalUnique404 === 0}>
{value.totalUnique404}
{#if value.totalUnique404 === 0}
class:text-red-600={value.uniqueBrokenLinks > 0}
class:textgrey={value.uniqueBrokenLinks === 0}>
{numberWithCommas(value.uniqueBrokenLinks)}
{#if value.uniqueBrokenLinks === 0}
<i class="fas fa-check"></i>
{/if}
</span>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/containers/ScanCompare.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2438d9a

Please sign in to comment.