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(regulations-admin): Add affected regulation formatting #15857

Merged
merged 4 commits into from
Sep 9, 2024

Conversation

thordurhhh
Copy link
Member

@thordurhhh thordurhhh commented Sep 2, 2024

What

Add affected article text at the end of change regulation.
Order articles by affected article number.

Why

Feature request.

Screenshot

Screenshot 2024-09-06 at 10 58 36

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 formatting for regulatory texts, improving clarity and maintainability.
    • Introduced a new function to format affected impacts, ensuring they are placed at the end of the output.
  • Bug Fixes
    • Streamlined logic for matching specific criteria, improving performance and accuracy.
    • Updated handling of amending titles to ensure uniqueness.
  • Refactor
    • Improved structure of utility functions for better separation of concerns and readability.

Copy link
Contributor

coderabbitai bot commented Sep 2, 2024

Walkthrough

The changes to the formatAmendingRegulation.ts file enhance the functionality of the formatAmendingRegulation utility. Key modifications include the introduction of new helper functions, restructuring of existing logic, and improvements to the formatting of regulatory texts. Notable updates involve the addition of the formatAffectedAndPlaceAffectedAtEnd function, streamlined string matching logic, and refined handling of amending titles and impact addition arrays.

Changes

File Path Change Summary
libs/portals/admin/regulations-admin/src/utils/formatAmendingRegulation.ts - Added formatAffectedAndPlaceAffectedAtEnd function for formatting affected impacts.
- Streamlined isGildisTaka function for clarity.
- Modified handling of amending titles for uniqueness.
- Updated formatAmendingRegBody to enhance clarity and remove redundancy.
- Refactored impactAdditionArray to return structured data.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FormatUtility
    participant DateFormatter
    participant ArticleExtractor

    User->>FormatUtility: Request to format regulation
    FormatUtility->>DateFormatter: Format date
    FormatUtility->>ArticleExtractor: Extract article number
    FormatUtility->>FormatUtility: Format affected impacts
    FormatUtility->>FormatUtility: Construct final output
    FormatUtility-->>User: Return formatted regulation
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

Copy link

codecov bot commented Sep 2, 2024

Codecov Report

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

Project coverage is 36.91%. Comparing base (b07ef91) to head (f148cf9).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ations-admin/src/utils/formatAmendingRegulation.ts 0.00% 75 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15857      +/-   ##
==========================================
+ Coverage   36.85%   36.91%   +0.05%     
==========================================
  Files        6692     6679      -13     
  Lines      136964   136288     -676     
  Branches    38913    38697     -216     
==========================================
- Hits        50481    50311     -170     
+ Misses      86483    85977     -506     
Flag Coverage Δ
portals-admin-regulations-admin 1.96% <0.00%> (-0.05%) ⬇️

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

Files with missing lines Coverage Δ
...ations-admin/src/utils/formatAmendingRegulation.ts 0.00% <0.00%> (ø)

... and 66 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 b07ef91...f148cf9. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 2, 2024

Datadog Report

Branch report: regulations-admin/affected-regulations-formatting
Commit report: 70a703d
Test service: portals-admin-regulations-admin

✅ 0 Failed, 24 Passed, 0 Skipped, 14.8s Total Time
🔻 Test Sessions change in coverage: 1 decreased (-0.07%)

🔻 Code Coverage Decreases vs Default Branch (1)

@thordurhhh thordurhhh marked this pull request as ready for review September 6, 2024 10:57
@thordurhhh thordurhhh requested a review from a team as a code owner September 6, 2024 10:57
@thordurhhh thordurhhh added the automerge Merge this PR as soon as all checks pass label Sep 6, 2024
coderabbitai[bot]
coderabbitai bot previously requested changes Sep 6, 2024
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: 4

Outside diff range, codebase verification and nitpick comments (1)
libs/portals/admin/regulations-admin/src/utils/formatAmendingRegulation.ts (1)

Line range hint 142-164: Optimization of Title Formatting in formatAmendingRegTitle

The function formatAmendingRegTitle has been updated to format regulation titles more effectively. The use of uniq and array mapping is appropriate here. However, consider the following points:

  1. Duplication: The logic for prefixing titles seems repetitive and could be abstracted into a smaller helper function to improve code reuse.
  2. Performance: Using map and filter consecutively can be merged into a single iteration to enhance performance.

These changes can make the function more efficient and maintainable.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd4618f and 3298415.

Files selected for processing (1)
  • libs/portals/admin/regulations-admin/src/utils/formatAmendingRegulation.ts (8 hunks)
Additional context used
Path-based instructions (1)
libs/portals/admin/regulations-admin/src/utils/formatAmendingRegulation.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."

Copy link
Member

@thorkellmani thorkellmani left a comment

Choose a reason for hiding this comment

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

LGTM 🏎️

@kodiakhq kodiakhq bot merged commit 87a976d into main Sep 9, 2024
30 checks passed
@kodiakhq kodiakhq bot deleted the regulations-admin/affected-regulations-formatting branch September 9, 2024 03:25
thoreyjona pushed a commit that referenced this pull request Sep 9, 2024
* Add affected regulation formatting

* Order articles by affected article number
jonnigs pushed a commit that referenced this pull request Sep 12, 2024
* Add affected regulation formatting

* Order articles by affected article number
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.

2 participants