-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set dataset status to 'Error' if any active endpoints have 'Error' status #716
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Coverage Report
File Coverage
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks good - can we get product sign off on this? cc @CharliePatterson
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
src/middleware/overview.middleware.js (1)
284-290
: Consider caching the Set lookup result.While the implementation is correct, for better performance, consider caching the Set lookup result when iterating through datasets:
const datasetsWithEndpointErrors = new Set(datasetErrorStatus.map(item => item.dataset)) for (const dataset of datasets) { dataset.project = provisionData.get(dataset.dataset)?.project - if (dataset.status !== 'Error' && datasetsWithEndpointErrors.has(dataset.dataset)) { + const hasEndpointErrors = datasetsWithEndpointErrors.has(dataset.dataset) + if (dataset.status !== 'Error' && hasEndpointErrors) { dataset.status = 'Error' } }test/unit/middleware/overview.middleware.test.js (1)
106-121
: Consider adding edge case tests.While the current test is good, consider adding these test cases:
- Multiple datasets with errors
- Empty datasetErrorStatus array
- Dataset already in error state
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/middleware/overview.middleware.js
(4 hunks)src/services/performanceDbApi.js
(1 hunks)test/unit/middleware/overview.middleware.test.js
(8 hunks)
🔇 Additional comments (3)
src/middleware/overview.middleware.js (2)
39-50
: LGTM! Well-structured middleware implementation.
The middleware function is correctly implemented using the fetchMany
builder and properly integrated into the middleware chain.
293-296
: LGTM! Efficient statistics calculation.
The use of array reduce for calculating multiple statistics in a single pass is an excellent approach.
test/unit/middleware/overview.middleware.test.js (1)
21-64
: LGTM! Well-structured test template.
The request template provides a comprehensive set of test data and follows good practices for test setup.
What type of PR is this? (check all applicable)
Description
On LPA overview page, we want to show datasets' status as 'Error' when any active endpoints are in error state. To do it we fetch extra info from
provision_summary
table.Related Tickets & Documents
Note: this should be merged after #714
QA Instructions, Screenshots, Recordings
Example: http://submit.planning.data.gov.uk/organisations/local-authority:ROH
Before
After
Added/updated tests?
QA sign off
Summary by CodeRabbit
New Features
Bug Fixes
Tests