From ab9cb7f131fa8472b7313fbd911fcfa317cf2dbf Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Mon, 24 Nov 2025 13:28:22 +0000 Subject: [PATCH 1/3] remove fetch entryissuecounts, fetchresources and entity count in dashboard --- src/middleware/lpa-overview.middleware.js | 30 +++++++---------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/middleware/lpa-overview.middleware.js b/src/middleware/lpa-overview.middleware.js index 7d151463f..e95e577a4 100644 --- a/src/middleware/lpa-overview.middleware.js +++ b/src/middleware/lpa-overview.middleware.js @@ -5,8 +5,8 @@ */ import performanceDbApi from '../services/performanceDbApi.js' -import { expectationFetcher, expectations, fetchEndpointSummary, fetchEntryIssueCounts, fetchOrgInfo, fetchResources, logPageError, noop, setAvailableDatasets } from './common.middleware.js' -import { fetchMany, FetchOptions, renderTemplate, fetchOneFromAllDatasets, parallel } from './middleware.builders.js' +import { expectationFetcher, expectations, fetchEndpointSummary, fetchOrgInfo, logPageError, noop, setAvailableDatasets } from './common.middleware.js' +import { fetchMany, FetchOptions, renderTemplate, parallel } from './middleware.builders.js' import { getDeadlineHistory, requiredDatasets } from '../utils/utils.js' import _ from 'lodash' import logger from '../utils/logger.js' @@ -22,7 +22,7 @@ const fetchEntityIssueCountsPerformanceDb = fetchMany({ return performanceDbApi.fetchEntityIssueCounts(params.lpa) }, result: 'entityIssueCounts', - dataset: FetchOptions.performanceDb + dataset: FetchOptions.performanceDbentityCounts }) const fetchProvisions = fetchMany({ @@ -33,14 +33,6 @@ const fetchProvisions = fetchMany({ result: 'provisions' }) -const fetchEntityCounts = fetchOneFromAllDatasets({ - query: ({ req }) => ` - select count(entity) as entity_count - from entity - WHERE organisation_entity = '${req.orgInfo.entity}'`, - result: 'entityCounts' -}) - /** * Calculates overall "health" of the datasets (not)provided by an organisation. * @@ -70,6 +62,8 @@ const orgStatsReducer = (accumulator, dataset) => { * @description * This middleware function checks if a dataset has been submitted within a certain timeframe * and sets flags for due and overdue notices accordingly. + * + * Does not work and not used currently, TODO: fix or delete */ export const datasetSubmissionDeadlineCheck = (req, res, next) => { const { resources } = req @@ -120,6 +114,7 @@ export const datasetSubmissionDeadlineCheck = (req, res, next) => { next() } +// TODO: Not used, fix or delete export function groupResourcesByDataset (req, res, next) { const { resources } = req @@ -319,11 +314,9 @@ export const getOverview = renderTemplate({ }) export function groupIssuesCountsByDataset (req, res, next) { - const { entityIssueCounts, entryIssueCounts } = req + const { entityIssueCounts } = req - // merge arrays and handle undefined - const issueCounts = [...(entityIssueCounts || []), ...(entryIssueCounts || [])] - req.issues = issueCounts.reduce((acc, current) => { + req.issues = entityIssueCounts.reduce((acc, current) => { if (!acc[current.dataset]) { acc[current.dataset] = [] } @@ -359,18 +352,13 @@ const fetchOutOfBoundsExpectations = expectationFetcher({ export default [ parallel([ fetchOrgInfo, - fetchResources, fetchEndpointSummary, fetchEntityIssueCountsPerformanceDb, fetchProvisions ]), - parallel([ - fetchEntryIssueCounts, // needs fetchResources to complete - fetchEntityCounts // needs fetchOrgInfo to complete - ]), + setAvailableDatasets, isFeatureEnabled('expectationOutOfBoundsTask') ? fetchOutOfBoundsExpectations : noop, - groupResourcesByDataset, groupIssuesCountsByDataset, groupEndpointsByDataset, From ffdde91e4dd1ea4d67ab43d042d21f04194bf82c Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Mon, 24 Nov 2025 13:35:27 +0000 Subject: [PATCH 2/3] lint --- src/middleware/lpa-overview.middleware.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/lpa-overview.middleware.js b/src/middleware/lpa-overview.middleware.js index e95e577a4..17cd8d41f 100644 --- a/src/middleware/lpa-overview.middleware.js +++ b/src/middleware/lpa-overview.middleware.js @@ -22,7 +22,7 @@ const fetchEntityIssueCountsPerformanceDb = fetchMany({ return performanceDbApi.fetchEntityIssueCounts(params.lpa) }, result: 'entityIssueCounts', - dataset: FetchOptions.performanceDbentityCounts + dataset: FetchOptions.performanceDb }) const fetchProvisions = fetchMany({ From e29318d84b030d4f06570135873eb4e8093b5366 Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Mon, 24 Nov 2025 14:23:02 +0000 Subject: [PATCH 3/3] empty entity issue count handling --- src/middleware/lpa-overview.middleware.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/lpa-overview.middleware.js b/src/middleware/lpa-overview.middleware.js index 17cd8d41f..cdc7d3bcd 100644 --- a/src/middleware/lpa-overview.middleware.js +++ b/src/middleware/lpa-overview.middleware.js @@ -314,7 +314,7 @@ export const getOverview = renderTemplate({ }) export function groupIssuesCountsByDataset (req, res, next) { - const { entityIssueCounts } = req + const { entityIssueCounts = [] } = req req.issues = entityIssueCounts.reduce((acc, current) => { if (!acc[current.dataset]) {