@@ -15,7 +15,7 @@ const failedUrlRequestTemplate = 'results/failedUrlRequest'
1515const resultsTemplate = 'results/results'
1616
1717class ResultsController extends PageController {
18- /* Custom middleware */
18+ /* Custom middleware, currently the controller can load results/results, results/failedFileRequest and results/failedUrlRequest templates */
1919 middlewareSetup ( ) {
2020 super . middlewareSetup ( )
2121 this . use ( validateParams )
@@ -129,10 +129,8 @@ export async function fetchResponseDetails (req, res, next) {
129129 try {
130130 if ( req . locals . template !== failedFileRequestTemplate && req . locals . template !== failedUrlRequestTemplate ) {
131131 const detailsOpts = req . locals . detailsOptions ?? { }
132- const responseDetails = req . locals . template === resultsTemplate
133- // pageNumber starts with: 1, fetchResponseDetails parameter `pageOffset` starts with 0
134- ? await req . locals . requestData . fetchResponseDetails ( pageNumber - 1 , 50 , { severity : 'error' , ...detailsOpts } )
135- : await req . locals . requestData . fetchResponseDetails ( pageNumber - 1 , 50 , { ...detailsOpts } )
132+ // Original code used a if statement to check template and filter by error severity accordingly, but move to always showing all details in results/results template
133+ const responseDetails = await req . locals . requestData . fetchResponseDetails ( pageNumber - 1 , 50 , { ...detailsOpts } )
136134 req . locals . responseDetails = responseDetails
137135 }
138136 } catch ( e ) {
@@ -161,7 +159,8 @@ export const fieldToColumnMapping = ({ columns }) => {
161159export function setupTableParams ( req , res , next ) {
162160 if ( req . locals . template !== failedFileRequestTemplate && req . locals . template !== failedUrlRequestTemplate ) {
163161 const responseDetails = req . locals . responseDetails
164- let rows = responseDetails . getRowsWithVerboseColumns ( req . locals . requestData . hasErrors ( ) )
162+ // Optionally filter out all non - error rows from dataset
163+ let rows = responseDetails . getRowsWithVerboseColumns ( false )
165164 // remove any issues that aren't of severity error
166165 rows = rows . map ( ( row ) => {
167166 const { columns, ...rest } = row
@@ -368,6 +367,7 @@ export function getTotalRows (req, res, next) {
368367 const totalRows = Number . parseInt ( responseDetails . pagination . totalResults )
369368 // NOTE: the fallback number may not be accurate, but it's better than just giving up and throwing
370369 req . totalRows = Number . isInteger ( totalRows ) ? totalRows : responseDetails . getRows ( ) . length
370+ req . locals . totalRows = req . totalRows
371371 next ( )
372372}
373373
@@ -471,13 +471,8 @@ export function getPassedChecks (req, res, next) {
471471 }
472472 }
473473
474- // add task complete for how many rows are in the table
475- if ( totalRows > 0 ) {
476- passedChecks . unshift ( makePassedCheck ( `Found ${ totalRows } rows` ) )
477-
478- if ( tasks . length === 0 && missingColumnTasks . length === 0 ) {
479- passedChecks . push ( makePassedCheck ( 'All data is valid' ) )
480- }
474+ if ( totalRows > 0 && tasks . length === 0 && missingColumnTasks . length === 0 ) {
475+ passedChecks . push ( makePassedCheck ( 'All data is valid' ) )
481476 }
482477
483478 req . locals . passedChecks = passedChecks
0 commit comments