Skip to content

LPA Overview module rename#945

Merged
rosado merged 7 commits into
mainfrom
rosado/lpa-overview-refactor
Mar 6, 2025
Merged

LPA Overview module rename#945
rosado merged 7 commits into
mainfrom
rosado/lpa-overview-refactor

Conversation

@rosado
Copy link
Copy Markdown
Contributor

@rosado rosado commented Mar 4, 2025

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

  • Refactor
  • Documentation Update

Description

Rename module to something more informative and some JSDoc updates.

Added/updated tests?

  • No: just a module rename and JSDoc changes

QA sign off

Summary by CodeRabbit

  • Bug Fixes
    • Organisation overview pages now correctly display membership status for the Open Digital Planning programme, ensuring that the appropriate membership message appears reliably.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 4, 2025

Walkthrough

The changes update import paths, documentation, and naming conventions across multiple modules. The middleware handling for organisation overviews now uses a new middleware file, and variable names have been standardised from isOPDMember to isODPMember. In addition, documentation has been enhanced in various middleware builder functions, typedefs extended in dataset overview handlers, and error handling guidelines have been introduced. These updates are also reflected in the test suite and HTML view, ensuring consistency across the application.

Changes

File(s) Change Summary
src/controllers/OrganisationsController.js, test/unit/middleware/lpa-overview.middleware.test.js Updated import paths from overview.middleware.js to lpa-overview.middleware.js and modified test descriptions and expected template parameters (renamed isOPDMember to isODPMember).
src/middleware/lpa-overview.middleware.js Revised module-level documentation, updated JSDoc annotations (parameter type changes and addition of optional req.templateParams), and renamed variable from isOPDMember to isODPMember in template preparation.
src/middleware/middleware.builders.js Enhanced documentation comments for multiple middleware functions by updating parameter annotations, modifying descriptions, and adjusting return type information.
src/routes/schemas.js, src/views/organisations/overview.html Renamed schema property and conditional check variable from isOPDMember to isODPMember for consistency.
src/middleware/datasetOverview.middleware.js Extended the Source typedef with new properties and updated prepareDatasetOverviewTemplateParams to include additional request parameters.
docs/Middleware Guidelines.md Added a new "Errors" section with guidelines on using MiddlewareError for rendering HTTP error pages.

Possibly related PRs

Suggested labels

tech debt

Suggested reviewers

  • GeorgeGoodall-GovUk

Poem

Oh, what a hop, what a bound,
In the code garden, treasures are found.
Imports and docs now prance in tune,
With renamed variables under the moon.
I, a clever rabbit, cheer this festive tune! 🐰


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b1536e and b397f35.

📒 Files selected for processing (2)
  • src/routes/schemas.js (1 hunks)
  • test/unit/middleware/lpa-overview.middleware.test.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/routes/schemas.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (4)
test/unit/middleware/lpa-overview.middleware.test.js (4)

2-2: Import path correctly updated to reflect module rename.

The import path has been updated from overview.middleware to lpa-overview.middleware.js, making the middleware's purpose clearer as it's specifically for Local Planning Authority overviews. The explicit .js extension is also added, which is a good practice for consistency.


66-66: Test suite description updated to match renamed module.

The describe block title has been updated to maintain consistency with the new module name, making it clear that these tests specifically cover the LPA overview middleware functionality.


102-102: Property name standardised from isOPDMember to isODPMember.

This change correctly standardises the acronym for Open Digital Planning (ODP), fixing the previous incorrect ordering. This ensures consistency in the codebase and better aligns with how the program is referred to in line 112.


164-164: Property name standardised from isOPDMember to isODPMember.

This change correctly standardises the acronym for Open Digital Planning (ODP), fixing the previous incorrect ordering. This ensures consistency with the earlier instance (line 102) and elsewhere in the codebase.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 for 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rosado rosado changed the title rename overview.middleware to lpa-overview.middleware, some JSDoc LPA Overview module rename Mar 4, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 4, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 66.8% 5455 / 8165
🔵 Statements 66.8% 5455 / 8165
🔵 Functions 64.18% 233 / 363
🔵 Branches 80.42% 719 / 894
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/controllers/OrganisationsController.js 0% 0% 0% 0% 1-25
src/middleware/datasetOverview.middleware.js 83.41% 61.53% 33.33% 83.41% 9-29, 65-69, 80-85, 122-124, 192
src/middleware/middleware.builders.js 76.42% 85% 68.18% 76.42% 45-47, 50, 119-130, 151-175, 192-212, 225-238, 251-254, 304-305, 386-389, 410-418
src/routes/schemas.js 100% 100% 100% 100%
Generated in workflow #937 for commit b397f35 by the Vitest Coverage Report Action

@rosado rosado force-pushed the rosado/lpa-overview-refactor branch from cda1a7b to 3bb2afa Compare March 4, 2025 12:23
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/middleware/datasetOverview.middleware.js (1)

240-255: 💡 Verification agent

🧩 Analysis chain

Consider updating the comment on line 250.

There's a commented-out middleware with a reference to an issue (#824). As part of documentation improvements, it might be worth checking if this issue has been resolved or if there's an updated plan for this functionality.


🏁 Script executed:

#!/bin/bash
# Check if issue #824 is still open

gh issue view 824 --json state,title,url || echo "Issue might not exist or you don't have access"

Length of output: 183


Action: Update Comment on Line 250

The commented-out middleware now refers to issue #824, which has been closed. Please update the inline comment in src/middleware/datasetOverview.middleware.js at line 250 to reflect the closed status. Consider either clarifying the current plan for this middleware (if reactivation is intended) or removing the unnecessary commented code to avoid confusion.

🧹 Nitpick comments (1)
docs/Middleware Guidelines.md (1)

54-55: Nitpick: Article Correction for Improved Clarity
Consider adding the indefinite article "an" before "appropriate HTTP error page" to improve the grammatical flow of the sentence. For example, change:

-...trigger the display of appropriate HTTP error page.
+...trigger the display of an appropriate HTTP error page.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~55-~55: Possible missing article found.
Context: ...hould be used to trigger the display of appropriate HTTP error page. For example, to presen...

(AI_HYDRA_LEO_MISSING_AN)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cda1a7b and 5b1536e.

📒 Files selected for processing (8)
  • docs/Middleware Guidelines.md (1 hunks)
  • src/controllers/OrganisationsController.js (1 hunks)
  • src/middleware/datasetOverview.middleware.js (2 hunks)
  • src/middleware/lpa-overview.middleware.js (5 hunks)
  • src/middleware/middleware.builders.js (8 hunks)
  • src/routes/schemas.js (1 hunks)
  • src/views/organisations/overview.html (1 hunks)
  • test/unit/middleware/overview.middleware.test.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/views/organisations/overview.html
  • src/controllers/OrganisationsController.js
  • src/routes/schemas.js
  • test/unit/middleware/overview.middleware.test.js
  • src/middleware/lpa-overview.middleware.js
  • src/middleware/middleware.builders.js
🧰 Additional context used
🪛 LanguageTool
docs/Middleware Guidelines.md

[uncategorized] ~55-~55: Possible missing article found.
Context: ...hould be used to trigger the display of appropriate HTTP error page. For example, to presen...

(AI_HYDRA_LEO_MISSING_AN)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (4)
docs/Middleware Guidelines.md (1)

52-53: New "Errors" Section Addition
The newly added section clearly explains the usage of the MiddlewareError for managing HTTP error responses in middleware. This enhancement to the documentation will assist developers in standardising error handling across the module.

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

139-145: Thorough JSDoc documentation added for the Source typedef properties.

The additions to the Source typedef provide comprehensive documentation for properties that are used in the codebase, particularly in the endpoints mapping function (lines 189-213). This improves code clarity and helps developers understand the structure of Source objects.


158-167: Improved parameter documentation for prepareDatasetOverviewTemplateParams.

The JSDoc has been significantly enhanced with detailed parameter types that accurately reflect the function's implementation. Especially noteworthy is the addition of the OUT parameter notation for req.templateParams, which clearly indicates that this is set by the function rather than consumed.


171-230: The implementation aligns well with the updated JSDoc.

The implementation of prepareDatasetOverviewTemplateParams correctly uses all the parameters now documented in the JSDoc. The function processes these inputs to calculate metrics and prepare template parameters that are set in req.templateParams, as indicated in the documentation.

@DilwoarH DilwoarH temporarily deployed to submit-pr-945 March 6, 2025 11:00 Inactive
@rosado rosado merged commit 5c747d3 into main Mar 6, 2025
@github-project-automation github-project-automation Bot moved this from Code review & QA to Ready for release in Providers team (BACKLOG) Mar 6, 2025
@rosado rosado deleted the rosado/lpa-overview-refactor branch March 6, 2025 11:15
@DilwoarH DilwoarH moved this from Ready for release to Done in Providers team (BACKLOG) Mar 6, 2025
@neilfwar neilfwar moved this from Done to Done Archived in Providers team (BACKLOG) Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done Archived

Development

Successfully merging this pull request may close these issues.

4 participants