Skip to content

update endpoint status check to only show error if all endpoints fail - #1063

Merged
feba-rajan merged 9 commits into
mainfrom
bugfix/provider-service-endpoint-status
Jul 9, 2025
Merged

update endpoint status check to only show error if all endpoints fail#1063
feba-rajan merged 9 commits into
mainfrom
bugfix/provider-service-endpoint-status

Conversation

@feba-rajan

@feba-rajan feba-rajan commented Jun 26, 2025

Copy link
Copy Markdown
Contributor

Description

This PR updates the logic in middleware for oragnisation overview page to ensure that the LPA dashboard only shows an "Error" status for a dataset if all its endpoints are failing (i.e., none have latest_status == '200')

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Before

Screenshot 2025-06-26 at 15 45 15

After

Screenshot 2025-06-26 at 15 07 06

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

  • Yes
  • No, and this is why: Please replace this line with details on why tests have not been included
  • I need help with writing tests

QA sign off

  • Code has been checked and approved
  • Design has been checked and approved
  • Product and business logic has been checked and proved

[optional] Are there any post-deployment tasks we need to perform?

[optional] Are there any dependencies on other PRs or Work?

Summary by CodeRabbit

  • New Features
    • Added display of each endpoint's entry date on the dataset overview page.
  • Bug Fixes
    • Improved detection and reporting of dataset endpoint errors, with clearer status assignment for "Live", "Needs fixing", or "Error".
    • Updated sorting of dataset endpoints to prioritise most recent entry dates.
  • Tests
    • Updated and added tests to cover new endpoint entry date field and enhanced error handling logic.

@coderabbitai

coderabbitai Bot commented Jun 26, 2025

Copy link
Copy Markdown
Contributor
## Walkthrough

The changes update how dataset endpoint error statuses are determined and displayed. Endpoints are now sorted by entry date, and an `entryDate` property is added and shown in the dataset overview. Related schema, middleware, and tests are updated to reflect these changes, including new logic for dataset status assignment and error handling.

## Changes

| Files/Paths                                                                 | Change Summary                                                                                                     |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| src/middleware/lpa-overview.middleware.js, test/unit/middleware/lpa-overview.middleware.test.js | Refined logic for determining dataset error status and messages based on all/some endpoint errors; expanded tests for new scenarios. |
| src/middleware/datasetOverview.middleware.js, test/unit/middleware/datasetOverview.middleware.test.js | Changed endpoint sorting to use `endpoint_entry_date`; added `entryDate` property to endpoints; updated related tests. |
| src/routes/schemas.js                                                       | Added optional, nullable `entryDate` string field to `endpoint` objects in `OrgDatasetOverview` schema.           |
| src/views/organisations/dataset-overview.html, test/unit/views/organisations/dataset-overview.test.js | Added display of `entryDate` for each endpoint in the dataset overview; updated tests for new field and formatting. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant Server
    participant Middleware
    participant View

    User->>Server: Request dataset overview
    Server->>Middleware: Prepare dataset objects
    Middleware->>Middleware: Sort endpoints by entryDate, assign error/status
    Middleware->>Server: Return dataset stats with entryDate
    Server->>View: Render dataset overview page with entryDate
    View-->>User: Display endpoints with entry date and status

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • DilwoarH

Poem

In the warren of code, a new date appears,
Endpoints now sorted by the newest of years.
Errors are counted with logic anew,
Status and messages more honest and true.
With every fresh entry, the overview’s bright—
🐇 Hopping forward, all data in sight!


<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 5cb7979935af6ef368d747ed4674a3b4acbb4fb3 and 1ca1c9efe4610ca94bf902157f64007cf6c16222.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `src/middleware/datasetOverview.middleware.js` (1 hunks)
* `test/unit/middleware/datasetOverview.middleware.test.js` (2 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (2)</summary>

* test/unit/middleware/datasetOverview.middleware.test.js
* src/middleware/datasetOverview.middleware.js

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (2)</summary>

* GitHub Check: test
* GitHub Check: run-tests / test

</details>

</details>
<!-- internal state start -->


<!-- D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4Ega4XWlQSeo6tutAEgU4AUDEdoa4Yws+o69oXujEUu9O8u2uqsKsEgTugQPujYDYNAK+zewe64a4NAa4I6hgU4IKIekgIKPuo6ruluhgKsO+4OqsS4BgPu9+04NBkgPu04YwgQK+7e/+nkNu0B84du4w4htAYw960QXW4w+B8ugQHuoKYwvutuxutuqsI6oKWgS4C4IKU4au5htAU4HB3uvu64Ehk4G4U4Nu2hiASAIBt+tu5htuwBwSS4Hia4S4ThvuphugCe7RgBmut1VQC+gQW4ee2R04HkSxlhtYCei4Ah7B9oNuow04I6vu9oSe2sPuuupBvhp+uBk6e+2RzO3AbOpRPO6cfaWgRgueomIAA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=digital-land/submit&utm_content=1063):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@github-actions

github-actions Bot commented Jun 26, 2025

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 66.46% 5962 / 8970
🔵 Statements 66.46% 5962 / 8970
🔵 Functions 64.87% 253 / 390
🔵 Branches 80.54% 770 / 956
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/middleware/datasetOverview.middleware.js 83.94% 66.66% 33.33% 83.94% 16-36, 77-81, 92-97, 134-136
src/middleware/lpa-overview.middleware.js 79.55% 80.95% 50% 79.55% 23, 31-33, 40-41, 79-81, 93-95, 101-103, 124-135, 152-154, 164-166, 213-214, 267-275, 320-333, 336-348
src/routes/schemas.js 100% 100% 100% 100%
Generated in workflow #1108 for commit 007c639 by the Vitest Coverage Report Action

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/middleware/lpa-overview.middleware.js (1)

218-222: LGTM! Logic correctly implements the requirement to show errors only when all endpoints fail.

The updated logic properly addresses the PR objective by using every() to check that all endpoints have non-200 status before showing an error. This prevents showing "Error" status when some endpoints are still functioning correctly.

Consider removing the commented-out code for cleanliness:

-    // const httpStatus = datasetEndpoints.find(endpoint => endpoint.latest_status !== '200')?.latest_status
-    // const error = httpStatus !== undefined ? `There was a ${httpStatus} error accessing the endpoint URL` : undefined
     const allError = datasetEndpoints.every(endpoint => endpoint.latest_status !== '200')

Additionally, the error message could be more accurate when multiple endpoints are involved:

-    const error = httpStatus !== undefined ? `There was a ${httpStatus} error accessing the endpoint URL` : undefined
+    const error = httpStatus !== undefined ? `There was a ${httpStatus} error accessing the endpoint URLs` : undefined
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 900f7f8 and 8b6b4cf.

📒 Files selected for processing (1)
  • src/middleware/lpa-overview.middleware.js (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: index.js:20-20
Timestamp: 2024-10-29T14:58:22.843Z
Learning: The function `initDatasetSlugToReadableNameFilter()` in `src/utils/datasetSlugToReadableName.js` already includes appropriate error handling and logging.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: test/unit/lpaDetailsController.test.js:20-20
Timestamp: 2024-10-29T15:06:42.432Z
Learning: The function `initDatasetSlugToReadableNameFilter()` includes its own error handling, so additional try-catch blocks around it in test files are unnecessary.
src/middleware/lpa-overview.middleware.js (5)
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: index.js:20-20
Timestamp: 2024-10-29T14:58:22.843Z
Learning: The function `initDatasetSlugToReadableNameFilter()` in `src/utils/datasetSlugToReadableName.js` already includes appropriate error handling and logging.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: test/unit/lpaDetailsController.test.js:20-20
Timestamp: 2024-10-29T15:06:42.432Z
Learning: The function `initDatasetSlugToReadableNameFilter()` includes its own error handling, so additional try-catch blocks around it in test files are unnecessary.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#510
File: test/unit/middleware/datasetOverview.middleware.test.js:1-3
Timestamp: 2024-10-21T08:57:17.338Z
Learning: Tests for `pullOutDatasetSpecification` have been moved to `common.middleware.test`.
Learnt from: rosado
PR: digital-land/submit#657
File: test/unit/middleware/issueDetails.middleware.test.js:43-43
Timestamp: 2024-11-14T16:38:49.883Z
Learning: In `test/unit/middleware/issueDetails.middleware.test.js`, template params are verified with a schema, so it's acceptable for the test expectations to use primitive values while the test input uses an object for `issueEntitiesCount`.
Learnt from: rosado
PR: digital-land/submit#657
File: src/services/performanceDbApi.js:290-293
Timestamp: 2024-11-14T17:31:37.924Z
Learning: In the `getEntityCounts` function in `src/services/performanceDbApi.js`, errors are already logged through the `.catch(...)` handlers on each promise in the `requests` array.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test

coderabbitai Bot added a commit that referenced this pull request Jun 27, 2025
Docstrings generation was requested by @Ben-Hodgkiss.

* #1063 (comment)

The following files were modified:

* `src/middleware/lpa-overview.middleware.js`
@digital-land digital-land deleted a comment from coderabbitai Bot Jun 27, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
test/unit/middleware/lpa-overview.middleware.test.js (1)

161-161: Fix typo in test description.

There's a typo in the test description.

-    it('should not show an error if atleast one endpoint is 200', () => {
+    it('should not show an error if at least one endpoint is 200', () => {
test/unit/views/organisations/dataset-overview.test.js (1)

34-34: Consider date format for test consistency.

The entryDate values use ISO date format which should be fine for date-only strings. However, based on previous learnings about daylight saving issues, ensure these date strings don't cause timezone-related test failures.

Also applies to: 42-42

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b6b4cf and 7d0da94.

📒 Files selected for processing (7)
  • src/middleware/datasetOverview.middleware.js (1 hunks)
  • src/middleware/lpa-overview.middleware.js (1 hunks)
  • src/routes/schemas.js (1 hunks)
  • src/views/organisations/dataset-overview.html (1 hunks)
  • test/unit/middleware/datasetOverview.middleware.test.js (1 hunks)
  • test/unit/middleware/lpa-overview.middleware.test.js (4 hunks)
  • test/unit/views/organisations/dataset-overview.test.js (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • test/unit/middleware/datasetOverview.middleware.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/middleware/lpa-overview.middleware.js
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: index.js:20-20
Timestamp: 2024-10-29T14:58:22.843Z
Learning: The function `initDatasetSlugToReadableNameFilter()` in `src/utils/datasetSlugToReadableName.js` already includes appropriate error handling and logging.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#510
File: test/unit/middleware/datasetOverview.middleware.test.js:1-3
Timestamp: 2024-10-21T08:57:17.338Z
Learning: Tests for `pullOutDatasetSpecification` have been moved to `common.middleware.test`.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: test/unit/lpaDetailsController.test.js:20-20
Timestamp: 2024-10-29T15:06:42.432Z
Learning: The function `initDatasetSlugToReadableNameFilter()` includes its own error handling, so additional try-catch blocks around it in test files are unnecessary.
src/middleware/datasetOverview.middleware.js (4)
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#510
File: test/unit/middleware/datasetOverview.middleware.test.js:1-3
Timestamp: 2024-10-21T08:57:17.338Z
Learning: Tests for `pullOutDatasetSpecification` have been moved to `common.middleware.test`.
Learnt from: rosado
PR: digital-land/submit#657
File: test/unit/middleware/issueDetails.middleware.test.js:43-43
Timestamp: 2024-11-14T16:38:49.883Z
Learning: In `test/unit/middleware/issueDetails.middleware.test.js`, template params are verified with a schema, so it's acceptable for the test expectations to use primitive values while the test input uses an object for `issueEntitiesCount`.
Learnt from: rosado
PR: digital-land/submit#657
File: src/services/performanceDbApi.js:290-293
Timestamp: 2024-11-14T17:31:37.924Z
Learning: In the `getEntityCounts` function in `src/services/performanceDbApi.js`, errors are already logged through the `.catch(...)` handlers on each promise in the `requests` array.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#609
File: test/unit/noErrorsPage.test.js:68-68
Timestamp: 2024-11-12T10:54:09.485Z
Learning: In `test/unit/noErrorsPage.test.js`, avoid using `prettifyColumnName` for column headers because the table can contain spec fields, as requested by Alex.
test/unit/views/organisations/dataset-overview.test.js (4)
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#644
File: test/unit/util.test.js:72-74
Timestamp: 2024-11-13T14:25:37.041Z
Learning: In `test/unit/util.test.js`, avoid using ISO 8601 date strings (e.g., `'2024-05-15T00:00:00.000Z'`) in tests, as they cause issues with daylight saving. Instead, use date strings like `'Tue, 15 May 2024 00:00:00'`.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#510
File: test/unit/middleware/datasetOverview.middleware.test.js:1-3
Timestamp: 2024-10-21T08:57:17.338Z
Learning: Tests for `pullOutDatasetSpecification` have been moved to `common.middleware.test`.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#609
File: test/unit/noErrorsPage.test.js:68-68
Timestamp: 2024-11-12T10:54:09.485Z
Learning: In `test/unit/noErrorsPage.test.js`, avoid using `prettifyColumnName` for column headers because the table can contain spec fields, as requested by Alex.
Learnt from: rosado
PR: digital-land/submit#657
File: test/unit/middleware/issueDetails.middleware.test.js:43-43
Timestamp: 2024-11-14T16:38:49.883Z
Learning: In `test/unit/middleware/issueDetails.middleware.test.js`, template params are verified with a schema, so it's acceptable for the test expectations to use primitive values while the test input uses an object for `issueEntitiesCount`.
test/unit/middleware/lpa-overview.middleware.test.js (6)
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#510
File: test/unit/middleware/datasetOverview.middleware.test.js:1-3
Timestamp: 2024-10-21T08:57:17.338Z
Learning: Tests for `pullOutDatasetSpecification` have been moved to `common.middleware.test`.
Learnt from: rosado
PR: digital-land/submit#657
File: test/unit/middleware/issueDetails.middleware.test.js:43-43
Timestamp: 2024-11-14T16:38:49.883Z
Learning: In `test/unit/middleware/issueDetails.middleware.test.js`, template params are verified with a schema, so it's acceptable for the test expectations to use primitive values while the test input uses an object for `issueEntitiesCount`.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: test/unit/lpaDetailsController.test.js:20-20
Timestamp: 2024-10-29T15:06:42.432Z
Learning: The function `initDatasetSlugToReadableNameFilter()` includes its own error handling, so additional try-catch blocks around it in test files are unnecessary.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#609
File: test/unit/noErrorsPage.test.js:68-68
Timestamp: 2024-11-12T10:54:09.485Z
Learning: In `test/unit/noErrorsPage.test.js`, avoid using `prettifyColumnName` for column headers because the table can contain spec fields, as requested by Alex.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#644
File: test/unit/util.test.js:72-74
Timestamp: 2024-11-13T14:25:37.041Z
Learning: In `test/unit/util.test.js`, avoid using ISO 8601 date strings (e.g., `'2024-05-15T00:00:00.000Z'`) in tests, as they cause issues with daylight saving. Instead, use date strings like `'Tue, 15 May 2024 00:00:00'`.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: index.js:20-20
Timestamp: 2024-10-29T14:58:22.843Z
Learning: The function `initDatasetSlugToReadableNameFilter()` in `src/utils/datasetSlugToReadableName.js` already includes appropriate error handling and logging.
🧬 Code Graph Analysis (1)
test/unit/middleware/lpa-overview.middleware.test.js (1)
src/middleware/lpa-overview.middleware.js (8)
  • prepareOverviewTemplateParams (255-308)
  • req (75-75)
  • req (124-124)
  • req (149-149)
  • req (207-207)
  • req (320-320)
  • req (336-336)
  • prepareDatasetObjects (206-237)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (8)
test/unit/middleware/lpa-overview.middleware.test.js (4)

85-85: Minor formatting improvement.

The spacing adjustment in the anonymous callback functions improves code consistency and readability.

Also applies to: 120-120, 131-131, 155-155


161-175: Well-structured test for mixed endpoint statuses.

This test correctly validates the new logic where having at least one successful endpoint (status '200') prevents an error from being displayed whilst still showing 'Needs fixing' status due to the failing endpoints.


176-190: Comprehensive test for all endpoints failing.

This test properly validates that when all endpoints have non-200 status codes, an error message containing the status code is displayed and the dataset status is set to 'Error'. The test correctly matches the new middleware logic.


191-209: Thorough test for all endpoints successful.

This test appropriately validates the scenario where all endpoints have '200' status, ensuring no error is displayed and the status is set to 'Live'. The test data with multiple successful endpoints provides good coverage.

src/routes/schemas.js (1)

172-172: Schema addition looks correct.

The optional nullable entryDate field is properly defined and maintains backward compatibility.

src/views/organisations/dataset-overview.html (1)

168-177: Template addition follows existing patterns correctly.

The new "Endpoint entry date" row is properly implemented with appropriate null handling and date formatting.

test/unit/views/organisations/dataset-overview.test.js (1)

87-87: Test assertions updated correctly.

The new assertions properly verify that entryDate values are rendered in the summary list with correct formatting.

Also applies to: 92-92

src/middleware/datasetOverview.middleware.js (1)

228-228: EntryDate addition is correctly implemented.

The new entryDate property properly maps from source.endpoint_entry_date and aligns with the schema changes.

Comment thread src/middleware/datasetOverview.middleware.js Outdated
Comment thread src/middleware/datasetOverview.middleware.js

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d0da94 and 4c22e6a.

📒 Files selected for processing (1)
  • src/views/organisations/overview.html (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: index.js:20-20
Timestamp: 2024-10-29T14:58:22.843Z
Learning: The function `initDatasetSlugToReadableNameFilter()` in `src/utils/datasetSlugToReadableName.js` already includes appropriate error handling and logging.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#510
File: test/unit/middleware/datasetOverview.middleware.test.js:1-3
Timestamp: 2024-10-21T08:57:17.338Z
Learning: Tests for `pullOutDatasetSpecification` have been moved to `common.middleware.test`.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: test/unit/lpaDetailsController.test.js:20-20
Timestamp: 2024-10-29T15:06:42.432Z
Learning: The function `initDatasetSlugToReadableNameFilter()` includes its own error handling, so additional try-catch blocks around it in test files are unnecessary.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test

Comment thread src/views/organisations/overview.html Outdated
Comment thread src/middleware/datasetOverview.middleware.js Outdated
Comment thread test/unit/middleware/datasetOverview.middleware.test.js Outdated
@feba-rajan
feba-rajan merged commit 20c220b into main Jul 9, 2025
5 checks passed
@feba-rajan
feba-rajan deleted the bugfix/provider-service-endpoint-status branch July 9, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants