Skip to content

fix: ODP membership status#832

Merged
rosado merged 3 commits into
mainfrom
rosado/odp-membership-fix
Jan 29, 2025
Merged

fix: ODP membership status#832
rosado merged 3 commits into
mainfrom
rosado/odp-membership-fix

Conversation

@rosado
Copy link
Copy Markdown
Contributor

@rosado rosado commented Jan 28, 2025

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

  • Bug Fix

Description

The ODP membership status text on LPA overview pages is incorrect. Code that added project info to the datasets was erroneously removed in #730. Adding it back (with slight change).

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Going to the LPA overview pages, they should now correctly indicate whether the organisation is part of the programme or not.

Added/updated tests?

  • Yes

QA sign off

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

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new isOPDMember flag to indicate Open Digital Planning programme membership
  • Improvements

    • Updated organisation overview page to use a more direct method of checking programme membership
    • Refined middleware logic for handling organisation data
  • Testing

    • Enhanced unit tests to validate new membership feature and error card rendering

These changes improve the visibility and handling of Open Digital Planning programme membership information across the application.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 28, 2025

Walkthrough

The pull request introduces changes to the overview middleware, schema, and view components to add a new isOPDMember flag. This flag determines an organisation's membership in the Open Digital Planning (ODP) programme. The modifications involve updating the middleware to calculate this membership status, adding the new property to the schema, and adjusting the view to use the new boolean flag instead of the previous project-based check.

Changes

File Change Summary
src/middleware/overview.middleware.js - Moved provisionData declaration
- Added isOPDMember calculation
- Updated req.templateParams with new flag
src/routes/schemas.js - Added isOPDMember: v.boolean() to OrgOverviewPage schema
src/views/organisations/overview.html - Replaced dataset project check with isOPDMember boolean
test/unit/middleware/overview.middleware.test.js - Updated getRenderedErrorCards function signature
- Added isOPDMember test cases

Sequence Diagram

sequenceDiagram
    participant Middleware
    participant Schema
    participant View
    
    Middleware->>Middleware: Calculate isOPDMember
    Middleware->>Schema: Add isOPDMember property
    Middleware->>View: Pass isOPDMember flag
    View->>View: Render membership status
Loading

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • CharliePatterson
  • GeorgeGoodall-GovUk
  • DilwoarH

Poem

🐰 A rabbit's tale of code so bright,
Where OPD members come to light
With flags and checks, we now can see
Who joins the digital planning spree!
Middleware magic, schema's delight 🌟

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 28, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 69.22% 5465 / 7895
🔵 Statements 69.22% 5465 / 7895
🔵 Functions 67.28% 216 / 321
🔵 Branches 81.76% 695 / 850
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/middleware/overview.middleware.js 70.17% 82.92% 41.66% 70.17% 11-13, 23, 31-33, 40-41, 76-78, 90-92, 98-100, 121-132, 149-151, 161-163, 191-219, 238-247, 292-305, 308-320
src/routes/schemas.js 100% 100% 100% 100%
Generated in workflow #676 for commit 567b27b by the Vitest Coverage Report Action

@rosado rosado added the bug Something isn't working label Jan 28, 2025
@eveleighoj eveleighoj temporarily deployed to submit-pr-832 January 29, 2025 10:37 Inactive
@rosado rosado marked this pull request as ready for review January 29, 2025 10:49
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

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

250-250: Consider using Array.some() for better performance.

The isOPDMember check could be optimised by using Array.some() instead of findIndex >= 0.

-const isOPDMember = provisions.findIndex((p) => p.project === 'open-digital-planning') >= 0
+const isOPDMember = provisions.some((p) => p.project === 'open-digital-planning')
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2e30a10 and 567b27b.

📒 Files selected for processing (4)
  • src/middleware/overview.middleware.js (3 hunks)
  • src/routes/schemas.js (1 hunks)
  • src/views/organisations/overview.html (1 hunks)
  • test/unit/middleware/overview.middleware.test.js (3 hunks)
🔇 Additional comments (8)
src/routes/schemas.js (1)

133-134: LGTM! Schema update correctly defines ODP membership.

The addition of the mandatory isOPDMember boolean property to the OrgOverviewPage schema is appropriate for tracking an organisation's ODP membership status.

src/middleware/overview.middleware.js (2)

230-233: LGTM! Map initialization is correctly positioned.

The provisionData map initialization and population is appropriately placed after the destructuring of request properties.


275-276: LGTM! Template params correctly include membership status.

The isOPDMember flag is properly included in the template parameters.

test/unit/middleware/overview.middleware.test.js (4)

67-76: LGTM! Function signature and documentation improved.

The getRenderedErrorCards function now correctly returns both error cards and document, with proper JSDoc documentation.


101-102: LGTM! Test params updated with membership status.

The expected template parameters now include the isOPDMember flag.


111-121: LGTM! Comprehensive test coverage for membership status.

The test cases thoroughly verify the rendering of membership information for both ODP members and non-members.


163-164: LGTM! Overview test includes membership status.

The getOverview test correctly includes the isOPDMember flag in the template parameters.

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

Line range hint 142-146: LGTM! Membership status display logic simplified.

The template now uses the dedicated isOPDMember flag instead of checking dataset properties, making the logic clearer and more maintainable.

Copy link
Copy Markdown
Contributor

@GeorgeGoodall-GovUk GeorgeGoodall-GovUk left a comment

Choose a reason for hiding this comment

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

looks good

@rosado rosado merged commit 9221238 into main Jan 29, 2025
@rosado rosado deleted the rosado/odp-membership-fix branch January 29, 2025 11:07
@coderabbitai coderabbitai Bot mentioned this pull request Mar 4, 2025
3 tasks
@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

bug Something isn't working

Projects

No open projects
Status: Done Archived

Development

Successfully merging this pull request may close these issues.

4 participants