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 address and postal code to user entity #2

Closed
wants to merge 3 commits into from
Closed

Conversation

giangle-mfv
Copy link
Owner

@giangle-mfv giangle-mfv commented Jun 24, 2024

  1. Why this PR is needed
    https://moneyforwardvietnam.atlassian.net/browse/SCI-1112
  2. What I did in this PR
  • Add address and postal code to user entity
  1. How to check

  2. Checklist

  • [] Pass all current unit-test
  • [] I have performed a self-review and test of my code
  • [] Check sql generated (if have) to ensure perf issue
  • [] Do you have any new properties? If then you need to create properties
    on: task_definition_app.json, task_definition_app_beta.json and AWS paramStore
  • [] If this is PR to STG/PROD plz prepare liquibase script

Summary by CodeRabbit


  • New Feature: Added new fields to the User entity. Users can now provide their address, postal code, and birth date for a more personalized experience.
  • New Feature: Introduced a unique slug field to the Category entity. This will enhance category identification and searchability across the platform.

Copy link

cr-gpt bot commented Jun 24, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

private String address;

@Column(unique = true)
private String postalCode;

@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(name = "users_roles",

Choose a reason for hiding this comment

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

Code Review:

Bug risks:

  1. Potentially missing nullability check for address field as it does not have the nullable = false attribute specified.
  2. The postalCode field is marked as unique, but postal codes are not always unique and may lead to constraint violations if not enforced properly.

Improvement suggestions:

  1. Consider adding validation annotations like @NotBlank or custom validations to ensure data integrity for fields like name, username, email, password, and potentially address.
  2. Documenting fields and methods in the code for better readability and maintainability.
  3. Add appropriate indexes on columns based on their usage in queries to optimize database performance.
  4. Use more specific fetch strategies other than FetchType.EAGER if possible to avoid potential performance issues when loading entities.
  5. Handle potential exceptions that might occur during database operations to improve error handling and maintain reliability.
  6. Consider refactoring code into smaller, more manageable classes if the User class becomes too large or complex.

Remember that further specific optimizations or improvements would depend on the context of how this class is being used within the application.

Copy link

github-actions bot commented Jun 26, 2024

Image description CodeRabbit

Walkthrough

The changes introduced in this pull request primarily focus on expanding the data model of our application. New fields have been added to the Category and User entities, enhancing their functionality and providing more detailed user profiles and category identification.

Changes

File Summary
src/main/java/com/springboot/blog/entity/Category.java
src/main/java/com/springboot/blog/entity/User.java
Introduced new fields to the Category and User entities. The Category entity now includes a unique slug field for better identification. The User entity has been enriched with address, postalCode, and birthDate fields, improving the detail level of user profiles.

🐇💻

"In the land of code where the shadows lie,

We update, we change, we always try.

New fields are born, as time does fly,

In User and Category, under the digital sky.

With every commit, we reach new high,

In the land of code, where the shadows lie." 🌙✨


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 4fafb40 and 4c849ee commits.
Files selected (2)
  • src/main/java/com/springboot/blog/entity/Category.java (1)
  • src/main/java/com/springboot/blog/entity/User.java (2)
Files skipped from review due to trivial changes (1)
  • src/main/java/com/springboot/blog/entity/Category.java
Review comments generated (2)
  • Review: 2
  • LGTM: 0

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

@@ -6,6 +6,7 @@
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Date;

Choose a reason for hiding this comment

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

Image description CodeRabbit

The import statement for java.util.Date has been added. However, it's recommended to use java.time.LocalDate or java.time.LocalDateTime instead of java.util.Date for date-time manipulation in modern Java applications. The newer classes provide a more comprehensive and user-friendly operation set.

- import java.util.Date;
+ import java.time.LocalDate;

Comment on lines +36 to +41
private String address;

@Column(unique = true)
private String postalCode;

private Date birthDate;

Choose a reason for hiding this comment

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

Image description CodeRabbit

New fields address, postalCode, and birthDate have been added to the User entity. However, there are no constraints on these fields. Consider adding appropriate constraints such as @Column(nullable = false) if these fields are mandatory. Also, making postalCode unique might not be suitable because multiple users can live in the same postal code area.

-    private String address;
+    @Column(nullable = false)
+    private String address;

-    @Column(unique = true)
-    private String postalCode;
+    private String postalCode;

-    private Date birthDate;
+    private LocalDate birthDate;

@giangle-mfv
Copy link
Owner Author

@coderabbitai: What is done in this pull request ?

Copy link

gitstream-cm bot commented Jun 27, 2024

🥷 Code experts: no user matched threshold 10

See details

src/main/java/com/springboot/blog/entity/Category.java

Knowledge based on git-blame:

src/main/java/com/springboot/blog/entity/User.java

Knowledge based on git-blame:

src/main/java/com/springboot/blog/payload/CategoryDto.java

Knowledge based on git-blame:

To learn more about /:\ gitStream - Visit our Docs

@giangle-mfv giangle-mfv deleted the update_user branch June 27, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant