From 1e6d91450a806c795c8606d1ed2e95b3ac442259 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Wed, 30 Oct 2024 16:01:12 +0000 Subject: [PATCH] add overwritten token to entry table --- src/middleware/issueDetails.middleware.js | 7 +++++-- src/services/performanceDbApi.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/middleware/issueDetails.middleware.js b/src/middleware/issueDetails.middleware.js index e6f938a7..db9c0a41 100644 --- a/src/middleware/issueDetails.middleware.js +++ b/src/middleware/issueDetails.middleware.js @@ -164,6 +164,9 @@ const processEntryRow = (issueType, issuesByEntryNumber, row) => { classes += 'dl-summary-card-list__row--error' } valueHtml += row.value + if (row.has_later_fact) { + valueHtml += '
(overwritten by more recent resource)' + } return getIssueField(row.field, valueHtml, classes) } @@ -173,13 +176,13 @@ const processEntryRow = (issueType, issuesByEntryNumber, row) => { */ export function prepareIssueDetailsTemplateParams (req, res, next) { const { entryData, pageNumber, issueEntitiesCount, issuesByEntryNumber, entryNumber, entityCount: entityCountRow } = req - const { lpa, dataset: datasetId, issue_type: issueType, issue_field: issueField } = req.params + const { lpa, dataset: datasetId, issue_type: issueType, issue_field: issueField, resource } = req.params const { entity_count: entityCount } = entityCountRow ?? { entity_count: 0 } let errorHeading let issueItems - const BaseSubpath = `/organisations/${lpa}/${datasetId}/${issueType}/${issueField}/` + const BaseSubpath = `/organisations/${lpa}/${datasetId}/${resource}/${issueType}/${issueField}/` if (Object.keys(issuesByEntryNumber).length < entityCount) { errorHeading = performanceDbApi.getTaskMessage({ issue_type: issueType, num_issues: issueEntitiesCount, entityCount, field: issueField }, true) diff --git a/src/services/performanceDbApi.js b/src/services/performanceDbApi.js index 8f00ce74..ab281e2e 100644 --- a/src/services/performanceDbApi.js +++ b/src/services/performanceDbApi.js @@ -415,7 +415,17 @@ export default { ft.field, ft.entry_date, ft.start_date, - ft.value + ft.value, + EXISTS ( + SELECT + 1 + FROM + fact ft2 + WHERE + ft2.entity = ft.entity + AND ft2.field = ft.field + AND ft2.entry_date > ft.entry_date + ) AS has_later_fact from fact_resource fr left join fact ft on fr.fact = ft.fact