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

fix(regulations-admin): Detection for new articles #14930

Merged
merged 5 commits into from
May 24, 2024

Conversation

thordurhhh
Copy link
Member

@thordurhhh thordurhhh commented May 24, 2024

What

Add detection for new complete articles.

Why

Improved detection for helper

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 handling of regulation titles and amendments in the admin portal.
  • Improvements

    • Improved logic for processing additions, deletions, and changes in regulation content.
    • Better handling of different element types such as 'lidur' and 'greinTitle'.
    • Refined detection and processing of changes in article titles and sections.

@thordurhhh thordurhhh added the automerge Merge this PR as soon as all checks pass label May 24, 2024
Copy link
Contributor

coderabbitai bot commented May 24, 2024

Walkthrough

The recent changes focus on enhancing the functionality and control flow in the regulations administration portal. A new function call updates the state with a formatted title in the EditBasics.tsx component. Additionally, significant modifications in the formatAmendingRegulation.ts utility include improved handling of various element types and refined logic for processing additions, deletions, and changes in articles and titles.

Changes

File Path Change Summary
libs/portals/admin/regulations-admin/src/components/EditBasics.tsx Added updateState('title', formatAmendingRegTitle(draft)) to update the state with the formatted title from the draft.
libs/portals/admin/regulations-admin/src/utils/formatAmendingRegulation.ts Enhanced logic for handling additions, deletions, and changes in articles and titles. Added isAddition property in testGroup and refined processing for various element types like 'lidur' and 'greinTitle'.

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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

@thordurhhh thordurhhh marked this pull request as ready for review May 24, 2024 16:24
@thordurhhh thordurhhh requested a review from a team as a code owner May 24, 2024 16:24
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

Outside diff range and nitpick comments (5)
libs/portals/admin/regulations-admin/src/components/EditBasics.tsx (3)

Line range hint 54-54: Include all dependencies in the useEffect hook to avoid potential bugs due to stale closures.

- useEffect(() => {
+ useEffect(() => {
+ }, [draft.type.value, draft.title.value, draft, updateState]) // Include all dependencies

Line range hint 67-67: Ensure all dependencies are specified in the useEffect hook to maintain correct behavior across re-renders.

- useEffect(() => {
+ useEffect(() => {
+ }, [draft.title.error, draft.type.value, draft.title.showError, t]) // Include all dependencies

Line range hint 102-102: Add missing dependencies to the useEffect hook to ensure it behaves as expected when dependencies change.

- useEffect(() => {
+ useEffect(() => {
+ }, [draft.type.value, text.value]) // Include all dependencies
libs/portals/admin/regulations-admin/src/utils/formatAmendingRegulation.ts (2)

Line range hint 77-267: Consider using for...of instead of forEach for better performance and readability when iterating over arrays.

- groupedArticles.forEach((group, i) => {
+ for (const [i, group] of groupedArticles.entries()) {

Line range hint 61-62: Avoid using template literals when not necessary for interpolation or special characters.

- `${i === 0 ? `${PREFIX_AMENDING}` : ''}${item.name.replace(
+ (i === 0 ? PREFIX_AMENDING : '') + item.name.replace(
Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 91ab0b7 and 007fcd8.
Files selected for processing (2)
  • libs/portals/admin/regulations-admin/src/components/EditBasics.tsx (1 hunks)
  • libs/portals/admin/regulations-admin/src/utils/formatAmendingRegulation.ts (7 hunks)
Additional Context Used
Biome (17)
libs/portals/admin/regulations-admin/src/components/EditBasics.tsx (12)

21-22: All these imports are only used as types.


26-27: All these imports are only used as types.


54-54: This hook specifies a dependency more specific that its captures: draft.type.value


54-54: This hook does not specify all of its dependencies: draft.title.value


54-54: This hook does not specify all of its dependencies: draft


54-54: This hook does not specify all of its dependencies: updateState


67-67: This hook does not specify all of its dependencies: draft.title.error


67-67: This hook does not specify all of its dependencies: draft.type.value


67-67: This hook does not specify all of its dependencies: draft.title.showError


67-67: This hook does not specify all of its dependencies: t


102-102: This hook does not specify all of its dependencies: draft.type.value


102-102: This hook does not specify all of its dependencies: text.value

libs/portals/admin/regulations-admin/src/utils/formatAmendingRegulation.ts (5)

61-62: Do not use template literals if interpolation and special-character handling are not needed.


99-250: Prefer for...of instead of forEach.


199-204: Prefer for...of instead of forEach.


1-1: Some named imports are only used as types.


1-2: All these imports are only used as types.

Path-based Instructions (2)
libs/portals/admin/regulations-admin/src/components/EditBasics.tsx (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."
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."

@datadog-island-is
Copy link

datadog-island-is bot commented May 24, 2024

Datadog Report

Branch report: regulations-admin/new-article-detection
Commit report: 524e92f
Test service: api

✅ 0 Failed, 4 Passed, 0 Skipped, 3.33s Total Time
➡️ Test Sessions change in coverage: 1 no change

Copy link

codecov bot commented May 24, 2024

Codecov Report

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

Project coverage is 37.08%. Comparing base (393bb7d) to head (e7f0265).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #14930      +/-   ##
==========================================
- Coverage   37.09%   37.08%   -0.01%     
==========================================
  Files        6353     6353              
  Lines      129379   129407      +28     
  Branches    36939    36950      +11     
==========================================
+ Hits        47990    47991       +1     
- Misses      81389    81416      +27     
Flag Coverage Δ
api 3.48% <ø> (ø)

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

Files Coverage Δ
...in/regulations-admin/src/components/EditBasics.tsx 0.00% <0.00%> (ø)
...ations-admin/src/utils/formatAmendingRegulation.ts 0.00% <0.00%> (ø)

... and 2 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 393bb7d...e7f0265. Read the comment docs.

@kodiakhq kodiakhq bot merged commit 5abdff4 into main May 24, 2024
30 checks passed
@kodiakhq kodiakhq bot deleted the regulations-admin/new-article-detection branch May 24, 2024 16:55
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