Skip to content
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

Add issue specification guidance to issueTable page #818

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

DilwoarH
Copy link
Contributor

@DilwoarH DilwoarH commented Jan 22, 2025

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

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

Description

Please replace this line with a brief description of the changes made.

Related Tickets & Documents

  • Ticket Link
  • Related Issue #
  • Closes #

QA Instructions, Screenshots, Recordings

Before

Before screenshot here

After

After screenshot here

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

Release Notes

  • New Features

    • Added issue specification guidance to the issue table view.
    • Enhanced issue table middleware to support additional specification details.
  • Improvements

    • Introduced a new optional property for more detailed issue specifications in the schema.
    • Added context-aware guidance for missing dataset columns.
  • Chores

    • Added a "Preview Link" section to the pull request template for enhanced visibility.

The update provides a more informative user experience by displaying contextual information about potential dataset issues and their recommended resolutions.

@DilwoarH DilwoarH linked an issue Jan 22, 2025 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Walkthrough

This pull request introduces a new function getIssueSpecification to handle issue specifications across multiple files. The function retrieves issue field specifications from request parameters and updates the middleware to pass this information to the template rendering logic. Additionally, an optional issueSpecification property is added to the OrgIssueTable schema, and the HTML view is updated to display guidance related to issue specifications when available.

Changes

File Change Summary
src/middleware/common.middleware.js Added getIssueSpecification function to retrieve issue field specifications
src/middleware/issueTable.middleware.js Imported getIssueSpecification and added issueSpecification to template parameters
src/routes/schemas.js Added optional issueSpecification property to OrgIssueTable schema
src/views/organisations/issueTable.html Added new section to display issue specification guidance using govukInsetText
.github/PULL_REQUEST_TEMPLATE.md Added new section for "Preview Link" in the pull request template

Possibly related PRs

  • fix: a few type errors #589: This PR modifies the src/middleware/common.middleware.js file, which is directly related to the main PR as it also involves changes to the same file, specifically the addition of new functions and modifications to existing middleware functionality.
  • update 'no-errors' page design & content #610: This PR introduces changes to the src/views/check/results/no-errors.html file, which may relate to how issue specifications are displayed in the UI. The addition of a back button in the main PR could enhance navigation related to issue specifications.
  • 684 issue details fetch data from all active resources #707: This PR modifies the src/middleware/common.middleware.js file, which is relevant as it also involves enhancements to middleware functions that could interact with the new getIssueSpecification function introduced in the main PR.

Suggested Labels

enhancement

Suggested Reviewers

  • GeorgeGoodall-GovUk

Poem

🐰 A rabbit's tale of specs so bright,
Middleware dancing with pure delight,
Issue guidance now takes flight,
With columns clear and context tight,
Code evolves with rabbit might! 🔍


📜 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 192c9e8 and 3cc9a34.

📒 Files selected for processing (3)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
  • src/middleware/common.middleware.js (1 hunks)
  • src/middleware/issueTable.middleware.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/middleware/issueTable.middleware.js
🧰 Additional context used
🪛 Markdownlint (0.37.0)
.github/PULL_REQUEST_TEMPLATE.md

23-23: null
Bare URL used

(MD034, no-bare-urls)

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

15-24: Format the preview link section properly.

The preview link section needs proper formatting:

  1. The URL should be formatted as a Markdown link
  2. The instructions should be more visible

Apply this diff to improve the formatting:

 ## Preview Link
 
-<!--
-Replace [PR_NUMBER] with the actual PR number to generate the preview URL.
-For example, for PR #818, the preview link would be:
-https://submit-pr-818.herokuapp.com/
--->
-
-https://submit-pr-[PR_NUMBER].herokuapp.com/
+> **Note**: Replace `[PR_NUMBER]` with the actual PR number to generate the preview URL.
+> For example, for PR #818, use: https://submit-pr-818.herokuapp.com/
+
+[Preview deployment](https://submit-pr-[PR_NUMBER].herokuapp.com/)
🧰 Tools
🪛 Markdownlint (0.37.0)

23-23: null
Bare URL used

(MD034, no-bare-urls)

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

688-697: Add JSDoc documentation to describe the middleware function.

The function implementation is correct, but it needs proper documentation.

Apply this diff to add JSDoc documentation:

+/**
+ * Middleware to retrieve issue field specification.
+ * 
+ * @param {Object} req - Express request object
+ * @param {Object} req.params - Request parameters
+ * @param {string} req.params.issue_field - The issue field to get specification for
+ * @param {Object} req.specification - The dataset specification
+ * @param {Array} req.specification.fields - Array of field specifications
+ * @param {Object} res - Express response object
+ * @param {Function} next - Express next middleware function
+ */
 export function getIssueSpecification (req, res, next) {
   const { issue_field: issueField } = req.params
   const { specification } = req
✨ 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.

Copy link

github-actions bot commented Jan 22, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 69.06% 5443 / 7881
🔵 Statements 69.06% 5443 / 7881
🔵 Functions 66.97% 215 / 321
🔵 Branches 81.77% 691 / 845
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/middleware/common.middleware.js 71.76% 90.09% 41.3% 71.76% 22-31, 35, 51-52, 54-55, 67-69, 73, 89-96, 177-178, 190-201, 207-229, 327, 336-338, 368-370, 408-422, 462-466, 471-474, 486-490, 518-532, 539-550, 556-564, 568-584, 646-647, 649-650, 652-653, 689-696, 720-727, 741-796
src/middleware/issueTable.middleware.js 98.48% 95.83% 85.71% 98.48% 44-45
src/routes/schemas.js 100% 100% 100% 100%
Generated in workflow #646 for commit 3cc9a34 by the Vitest Coverage Report Action

Copy link
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: 3

🧹 Nitpick comments (1)
src/views/organisations/issueTable.html (1)

100-128: Improve accessibility of the guidance link.

The implementation follows GOV.UK Design System patterns well. However, the guidance link could be more accessible.

Apply this diff to improve the link's accessibility:

-      <p class="govuk-body">The <a href="{{ dataset.dataset | getDatasetGuidanceUrl }}" target="_blank">{{ dataset.name }}</a> guidance explains how to fix the issue:</p>
+      <p class="govuk-body">The <a href="{{ dataset.dataset | getDatasetGuidanceUrl }}" target="_blank" rel="noopener noreferrer">{{ dataset.name }} guidance (opens in new tab)</a> explains how to fix the issue:</p>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2fcf34a and 65c3291.

📒 Files selected for processing (4)
  • src/middleware/common.middleware.js (1 hunks)
  • src/middleware/issueTable.middleware.js (4 hunks)
  • src/routes/schemas.js (1 hunks)
  • src/views/organisations/issueTable.html (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-tests / test
🔇 Additional comments (3)
src/middleware/issueTable.middleware.js (1)

Line range hint 77-89: LGTM! Template parameters are correctly updated.

The issueSpecification parameter is properly destructured from the request object and added to the template parameters.

src/routes/schemas.js (1)

214-219: LGTM! Schema definition is well-structured.

The issueSpecification property is properly defined with:

  • Appropriate optional wrapper
  • Strict object validation
  • Required and optional fields with proper types
src/views/organisations/issueTable.html (1)

7-7: LGTM! Macro import is correctly placed.

The govukInsetText macro is properly imported from the GOV.UK Design System.

@@ -7,7 +7,7 @@
*/

import config from '../../config/index.js'
import { createPaginationTemplateParams, fetchDatasetInfo, fetchOrgInfo, fetchResources, filterOutEntitiesWithoutIssues, getErrorSummaryItems, getSetBaseSubPath, getSetDataRange, logPageError, processEntitiesMiddlewares, processRelevantIssuesMiddlewares, processSpecificationMiddlewares, show404IfPageNumberNotInRange, validateQueryParams } from './common.middleware.js'
import { createPaginationTemplateParams, fetchDatasetInfo, fetchOrgInfo, fetchResources, filterOutEntitiesWithoutIssues, getErrorSummaryItems, getIssueSpecfication, getSetBaseSubPath, getSetDataRange, logPageError, processEntitiesMiddlewares, processRelevantIssuesMiddlewares, processSpecificationMiddlewares, show404IfPageNumberNotInRange, validateQueryParams } from './common.middleware.js'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the typo in the imported function name.

The imported function name contains a typo: getIssueSpecfication should be getIssueSpecification.

@@ -122,6 +123,7 @@
show404IfPageNumberNotInRange,
getSetBaseSubPath(),
getErrorSummaryItems,
getIssueSpecfication,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the typo in the middleware chain function name.

The function name in the middleware chain contains the same typo: getIssueSpecfication.

Comment on lines 688 to 696
export function getIssueSpecfication (req, res, next) {
const { issue_field: issueField } = req.params
const { specification } = req

const fieldSpecification = specification.fields.find(f => f.field === issueField)
req.issueSpecification = fieldSpecification ?? undefined

next()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix the typo and add JSDoc documentation.

The function implementation is correct, but there are two improvements needed:

  1. Fix the typo in the function name: getIssueSpecficationgetIssueSpecification
  2. Add JSDoc documentation to describe the function's purpose, parameters, and behaviour

Apply this diff to implement the improvements:

-export function getIssueSpecfication (req, res, next) {
+/**
+ * Middleware to retrieve issue field specification.
+ * 
+ * @param {Object} req - Express request object
+ * @param {Object} req.params - Request parameters
+ * @param {string} req.params.issue_field - The issue field to get specification for
+ * @param {Object} req.specification - The dataset specification
+ * @param {Array} req.specification.fields - Array of field specifications
+ * @param {Object} res - Express response object
+ * @param {Function} next - Express next middleware function
+ */
+export function getIssueSpecification (req, res, next) {
   const { issue_field: issueField } = req.params
   const { specification } = req
 
   const fieldSpecification = specification.fields.find(f => f.field === issueField)
   req.issueSpecification = fieldSpecification ?? undefined
 
   next()
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function getIssueSpecfication (req, res, next) {
const { issue_field: issueField } = req.params
const { specification } = req
const fieldSpecification = specification.fields.find(f => f.field === issueField)
req.issueSpecification = fieldSpecification ?? undefined
next()
}
/**
* Middleware to retrieve issue field specification.
*
* @param {Object} req - Express request object
* @param {Object} req.params - Request parameters
* @param {string} req.params.issue_field - The issue field to get specification for
* @param {Object} req.specification - The dataset specification
* @param {Array} req.specification.fields - Array of field specifications
* @param {Object} res - Express response object
* @param {Function} next - Express next middleware function
*/
export function getIssueSpecification (req, res, next) {
const { issue_field: issueField } = req.params
const { specification } = req
const fieldSpecification = specification.fields.find(f => f.field === issueField)
req.issueSpecification = fieldSpecification ?? undefined
next()
}

Copy link
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: 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 65c3291 and 192c9e8.

📒 Files selected for processing (1)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
🧰 Additional context used
🪛 Markdownlint (0.37.0)
.github/PULL_REQUEST_TEMPLATE.md

17-17: null
Bare URL used

(MD034, no-bare-urls)

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

Line range hint 1-14: The PR template structure looks good!

The template follows GitHub's best practices and includes comprehensive sections for documenting PRs effectively.

Also applies to: 19-89

🧰 Tools
🪛 Markdownlint (0.37.0)

17-17: null
Bare URL used

(MD034, no-bare-urls)

Comment on lines 15 to 17
## Preview Link

https://submit-pr-[PR_NUMBER].herokuapp.com/
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add guidance for the preview link section and format the URL properly.

The preview link section would benefit from clear instructions on how to use it. Additionally, the URL should be properly formatted as a Markdown link.

Apply this diff to improve the section:

 ## Preview Link
 
-https://submit-pr-[PR_NUMBER].herokuapp.com/
+<!--
+Replace [PR_NUMBER] with the actual PR number to generate the preview URL.
+For example, for PR #818, the preview link would be:
+https://submit-pr-818.herokuapp.com/
+-->
+
+[Preview deployment](https://submit-pr-[PR_NUMBER].herokuapp.com/)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Preview Link
https://submit-pr-[PR_NUMBER].herokuapp.com/
## Preview Link
<!--
Replace [PR_NUMBER] with the actual PR number to generate the preview URL.
For example, for PR #818, the preview link would be:
https://submit-pr-818.herokuapp.com/
-->
[Preview deployment](https://submit-pr-[PR_NUMBER].herokuapp.com/)
🧰 Tools
🪛 Markdownlint (0.37.0)

17-17: null
Bare URL used

(MD034, no-bare-urls)

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.

Technical spike: How will we surface guidance content snippets?
2 participants