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

Remove customer profile fields from creation schema and service #172

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

jamalsoueidan
Copy link
Owner

@jamalsoueidan jamalsoueidan commented Jul 3, 2024

PR Type

Enhancement, Bug fix


Description

  • Removed professions, aboutMe, aboutMeHtml, and shortDescription fields from the customer creation schema and service.
  • Made username field required in the user schema.
  • Added username field to the user creation in the test setup.
  • Fixed import formatting for GenerateAvailabilityProps in the test file.

Changes walkthrough 📝

Relevant files
Enhancement
create.ts
Simplify customer creation schema by removing profile fields

src/functions/customer/controllers/customer/create.ts

  • Removed professions, aboutMe, aboutMeHtml, and shortDescription fields
    from the customer creation schema.
  • +0/-4     
    create.ts
    Update customer service creation body type                             

    src/functions/customer/services/customer/create.ts

  • Updated CustomerServiceCreateBody type to exclude professions,
    aboutMe, aboutMeHtml, and shortDescription fields.
  • +1/-9     
    Bug fix
    user.schema.ts
    Set username field as required in user schema                       

    src/functions/user/user.schema.ts

    • Made username field required in the user schema.
    +1/-1     
    Tests
    generate-availability.spec.ts
    Add username field in test setup and fix import formatting

    src/library/availability/generate-availability.spec.ts

  • Added username field to the user creation in the test setup.
  • Fixed import formatting for GenerateAvailabilityProps.
  • +2/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @github-actions github-actions bot added enhancement New feature or request Bug fix labels Jul 3, 2024
    Copy link

    github-actions bot commented Jul 3, 2024

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review [1-5] 2
    🧪 Relevant tests No
    🔒 Security concerns No
    ⚡ Key issues to review Possible Bug:
    The removal of fields such as professions, aboutMe, aboutMeHtml, and shortDescription from the customer creation schema and service might impact other parts of the application that rely on these fields. Ensure that these changes do not break existing functionalities.
    Data Validation:
    The username field in the user schema is now required. Ensure that all existing and new code paths that create users handle this requirement correctly to avoid runtime errors.

    Copy link

    github-actions bot commented Jul 3, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Performance
    Reinstate the index property on the 'username' field for consistent indexing and performance

    Ensure that the 'username' field is consistently indexed across your schema definitions.
    If 'username' should be unique and indexed, it might be beneficial to maintain the 'index:
    true' property for consistency and performance, especially if queries on this field are
    frequent.

    src/functions/user/user.schema.ts [43-46]

     username: {
       type: String,
       unique: true,
    +  index: true,
       required: true,
     },
     
    Suggestion importance[1-10]: 9

    Why: Maintaining the 'index: true' property for the 'username' field ensures consistent indexing and can improve query performance, which is beneficial for frequently queried fields.

    9
    Enhancement
    Add validation for the 'speaks' field in the customer creation schema

    Consider validating the presence of the 'speaks' field in the schema since it is included
    in the customer creation schema. This ensures that all necessary data is validated and
    consistent with the schema requirements.

    src/functions/customer/controllers/customer/create.ts [15-19]

     customerId: true,
     fullname: true,
     username: true,
     gender: true,
    -speaks: true,
    +speaks: { required: true },
     
    Suggestion importance[1-10]: 8

    Why: Adding validation for the 'speaks' field ensures that all necessary data is validated and consistent with the schema requirements, which is important for data integrity.

    8
    Add a test case for handling the 'username' field in the 'generateAvailability' function

    Add a test case to verify the behavior of the 'generateAvailability' function when the
    'username' field is provided, as this field is now being included in the user model
    creation within tests.

    src/library/availability/generate-availability.spec.ts [102-106]

     UserModel.create({
       customerId,
       fullname: "jamal soueidan",
       username: "jamal",
     })
    +// Add test case here to verify 'username' handling
     
    Suggestion importance[1-10]: 6

    Why: Adding a test case to verify the behavior of the 'generateAvailability' function when the 'username' field is provided ensures that the new field is properly handled, improving test coverage and reliability.

    6
    Possible issue
    Update business logic and validations related to removed fields in the customer creation service

    Since fields like 'professions', 'aboutMe', and 'shortDescription' have been removed from
    the customer creation service, ensure that any business logic or validations that
    previously depended on these fields are also updated or removed to prevent runtime errors.

    src/functions/customer/services/customer/create.ts [3-5]

     export type CustomerServiceCreateBody = Pick<
       User,
       "customerId" | "fullname" | "username" | "gender" | "speaks"
     >;
    +// Ensure related business logic is updated accordingly
     
    Suggestion importance[1-10]: 7

    Why: Ensuring that any business logic or validations that previously depended on the removed fields are updated or removed helps prevent potential runtime errors, maintaining the robustness of the service.

    7

    @jamalsoueidan jamalsoueidan merged commit 3b05a86 into main Jul 3, 2024
    3 checks passed
    @jamalsoueidan jamalsoueidan deleted the create-user-with-minimal-info branch July 3, 2024 01:13
    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