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

feat(j-s): Add court name abbr. to prison cases table #17171

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Dec 7, 2024

Add court name abbr. to prison cases table

Asana

What

Add court name abbreviations to court case column in the indictments cases table for prisons.

Screenshots / Gifs

Uploading Screenshot 2024-12-07 at 20.38.38.png…

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Enhanced display of court case numbers with district court abbreviations.
    • Added a sortable property for court case numbers in the indictment table.
    • Introduced a new field in the GraphQL query to retrieve court-related information for each case.
  • Bug Fixes

    • Improved error handling for data fetching failures.

Copy link
Contributor

coderabbitai bot commented Dec 7, 2024

Walkthrough

The pull request introduces modifications to the PrisonCases component in the judicial system application. Key changes include the addition of the districtCourtAbbreviation function to enhance court case number displays, making them sortable in the indictment cases table. The rendering logic for case numbers has been updated, and memoization has been applied to optimize performance in rendering tables. Additionally, a new court field has been added to the GraphQL query for PrisonCases, allowing retrieval of court-related information.

Changes

File Path Change Summary
apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx - Added import for districtCourtAbbreviation.
- Updated renderIndictmentTable and renderTable methods for court case number formatting.
- Implemented useMemo for performance optimization.
- Minor adjustments to table headers.
apps/judicial-system/web/src/routes/Shared/Cases/prisonCases.graphql - Added court { id, name } field to the PrisonCases query for retrieving court-related information.

Possibly related PRs

Suggested labels

automerge, high priority

Suggested reviewers

  • unakb
  • gudjong

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 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.

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.

@oddsson oddsson marked this pull request as ready for review December 7, 2024 20:39
@oddsson oddsson requested a review from a team as a code owner December 7, 2024 20:39
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: 0

🧹 Outside diff range and nitpick comments (1)
apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx (1)

192-206: Simplify the court case number formatting logic.

While the implementation is functional, the nested template literals could be simplified for better readability.

Consider this cleaner implementation:

               cell: (row) => {
                 const courtAbbreviation = districtCourtAbbreviation(
                   row.court?.name,
                 )
+                const prefix = courtAbbreviation ? `${courtAbbreviation}: ` : ''
+                const caseNumber = row.courtCaseNumber ?? ''
 
                 return (
                   <CourtCaseNumber
-                    courtCaseNumber={`${
-                      courtAbbreviation ? `${courtAbbreviation}: ` : ''
-                    }${row.courtCaseNumber ?? ''}`}
+                    courtCaseNumber={`${prefix}${caseNumber}`}
                     policeCaseNumbers={row.policeCaseNumbers ?? []}
                     appealCaseNumber={row.appealCaseNumber ?? ''}
                   />
                 )
               },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1a6abd6 and 52459bf.

📒 Files selected for processing (2)
  • apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx (3 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/prisonCases.graphql (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
apps/judicial-system/web/src/routes/Shared/Cases/prisonCases.graphql (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (1)
apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx (1)
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
🔇 Additional comments (5)
apps/judicial-system/web/src/routes/Shared/Cases/prisonCases.graphql (1)

47-50: LGTM! The court field addition is well-structured.

The new court field with id and name subfields is appropriately placed and provides the necessary data for displaying court abbreviations.

apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx (4)

6-9: LGTM! Clean import restructuring.

The imports are well-organized and properly structured using named imports.


172-175: LGTM! Good addition of sorting capability.

Adding sorting for the case number column improves user experience and follows the established pattern for sortable columns.


Line range hint 65-206: LGTM! Excellent performance optimization.

The use of useMemo for table rendering functions is well-implemented with correct dependencies, preventing unnecessary re-renders of complex table structures.


Line range hint 1-206: Verify the court abbreviation display in the UI.

The implementation successfully adds court name abbreviations to the prison cases table. To ensure the feature works as expected, please verify:

  1. Court abbreviations are correctly displayed in the UI
  2. Sorting works properly with the new court prefix
✅ Verification successful

Court abbreviation implementation is correctly integrated

Based on the verification results, the implementation is complete and correct:

  1. The districtCourtAbbreviation formatter is properly implemented with mappings for all district courts (HDR, HDRN, HDV, etc.)
  2. The formatter is correctly imported and used in the PrisonCases component
  3. The court abbreviation is properly concatenated with the case number in the format {abbreviation}: {caseNumber}
  4. The implementation is consistent with other components in the codebase that use the same pattern
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of court abbreviations

# Check for the formatter function implementation
echo "Checking for district court abbreviation formatter..."
rg -A 5 "export.*districtCourtAbbreviation"

# Verify court name mapping
echo "Checking court name mapping..."
rg -A 10 "court.*name.*mapping|COURT.*MAPPING"

Length of output: 813


Script:

#!/bin/bash
# Let's verify the complete implementation by checking:
# 1. The GraphQL query to ensure court field is included
# 2. The full formatter implementation
# 3. Usage in the component

# Check the GraphQL query
echo "Checking GraphQL query for court field..."
rg -A 10 "prisonCasesQuery|PrisonCasesQuery" --type ts

# Check the complete formatter implementation
echo "Checking complete district court abbreviation implementation..."
rg -A 15 "districtCourtAbbreviation" --type ts

# Check the component's usage
echo "Checking usage in the component..."
ast-grep --pattern 'const courtAbbreviation = districtCourtAbbreviation($_)'

Length of output: 22172


Script:

#!/bin/bash
# Let's verify the GraphQL query definition to ensure court field is included
echo "Checking GraphQL query definition..."
rg -A 5 "query PrisonCases" --type graphql

# Check if the court field is included in the CaseListEntry type
echo "Checking CaseListEntry type definition..."
rg -A 15 "type CaseListEntry" --type graphql

Length of output: 331

Copy link

codecov bot commented Dec 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 35.77%. Comparing base (b22fd0a) to head (4522563).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...system/web/src/routes/Shared/Cases/PrisonCases.tsx 0.00% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17171      +/-   ##
==========================================
+ Coverage   35.75%   35.77%   +0.01%     
==========================================
  Files        6935     6933       -2     
  Lines      148065   148001      -64     
  Branches    42211    42181      -30     
==========================================
+ Hits        52942    52946       +4     
+ Misses      95123    95055      -68     
Flag Coverage Δ
api 3.33% <ø> (ø)
application-system-api 38.75% <ø> (ø)
application-ui-shell 22.47% <ø> (ø)
judicial-system-web 27.88% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...system/web/src/routes/Shared/Cases/PrisonCases.tsx 0.00% <0.00%> (ø)

... and 24 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b22fd0a...4522563. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 7, 2024

Datadog Report

All test runs 03cabb2 🔗

97 Total Test Services: 0 Failed, 89 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.19%), 199 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 63 0 23.34s N/A Link
air-discount-scheme-web 0 0 0 2 0 7.78s N/A Link
api 0 0 0 4 0 2.49s N/A Link
api-catalogue-services 0 0 0 23 0 9.05s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 19.26s N/A Link
api-domains-assets 0 0 0 3 0 11.78s N/A Link
api-domains-auth-admin 0 0 0 18 0 12.87s 1 no change Link
api-domains-communications 0 0 0 5 0 35.49s N/A Link
api-domains-criminal-record 0 0 0 5 0 9.79s 1 no change Link
api-domains-driving-license 0 0 0 23 0 27.31s N/A Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • clients-middlewares - jest 75.6% (-0.19%) - Details

Copy link
Member

@unakb unakb left a comment

Choose a reason for hiding this comment

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

lgtm

@unakb unakb added the automerge Merge this PR as soon as all checks pass label Dec 11, 2024
@thoreyjona thoreyjona removed the automerge Merge this PR as soon as all checks pass label Dec 12, 2024
@oddsson oddsson added the automerge Merge this PR as soon as all checks pass label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants