Skip to content

Add a field for customer id in Account#409

Merged
msk merged 1 commit intoaicers:mainfrom
kimhanbeom:david/issue-408
Mar 15, 2025
Merged

Add a field for customer id in Account#409
msk merged 1 commit intoaicers:mainfrom
kimhanbeom:david/issue-408

Conversation

@kimhanbeom
Copy link
Copy Markdown
Contributor

  • migration
    스크린샷 2025-03-10 오전 10 51 35

  • migration result
    스크린샷 2025-03-10 오전 10 52 19

Close: #408

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Hello @kimhanbeom, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request adds a customer_ids field to the Account struct in the review-database crate. This field is intended to store the customer ID(s) associated with a user account. The changes include modifications to the Account struct, its constructor, and migration logic to handle the new field during database upgrades. The version of the crate is also bumped to 0.36.0-alpha.1.

Highlights

  • Feature Addition: A customer_ids field (of type Option<Vec<u32>>) is added to the Account struct to store customer IDs associated with an account.
  • Constructor Modification: The Account::new constructor is updated to accept the new customer_ids parameter.
  • Migration Logic: Migration logic is added to handle the upgrade from previous versions (0.34.0) to the new version (0.36.0-alpha.1), including a new migration function migrate_0_34_0_to_0_36_alpha_1.
  • Version Bump: The crate version in Cargo.toml is updated from 0.35.0 to 0.36.0-alpha.1.
  • Changelog Update: The CHANGELOG.md file is updated to reflect the addition of the customer_ids field.

Changelog

Click here to see the changelog
  • CHANGELOG.md
    • Added Account::customer_ids field to store the customer id the user belongs to.
  • Cargo.toml
    • Bumped version from 0.35.0 to 0.36.0-alpha.1.
  • src/account.rs
    • Added customer_ids field to the Account struct.
    • Modified the Account::new constructor to accept customer_ids.
    • Added customer_ids to the test cases.
  • src/migration.rs
    • Added migration logic migrate_0_34_0_to_0_36_alpha_1 to handle the new customer_ids field.
    • Modified COMPATIBLE_VERSION_REQ to reflect the new version range.
    • Modified migrate_0_34_account to migrate to AccountBeforeV35.
    • Added AccountBeforeV35 struct to src/migration/migration_structures.rs
  • src/migration/migration_structures.rs
    • Added AccountBeforeV35 struct to represent the account structure before the customer_ids field was added.
  • src/tables/accounts.rs
    • Modified the Table::update function to handle updates to the customer_ids field.
    • Added customer_ids parameter to Table::update function.
    • Added None to the test cases for the new customer_ids parameter.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Trivia time!

What is the purpose of the Option type in Rust?

Click here for the answer
The `Option` type in Rust is used to represent the possibility of a value being absent. It can be either `Some(value)` if a value is present, or `None` if no value is present. This helps avoid null pointer exceptions.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist
Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 10, 2025

Codecov Report

Attention: Patch coverage is 88.80597% with 15 lines in your changes missing coverage. Please review.

Project coverage is 70.15%. Comparing base (2870c28) to head (0b8f01d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/migration.rs 91.56% 7 Missing ⚠️
src/tables/accounts.rs 36.36% 7 Missing ⚠️
src/migration/migration_structures.rs 97.22% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #409      +/-   ##
==========================================
+ Coverage   70.06%   70.15%   +0.09%     
==========================================
  Files          95       95              
  Lines       21392    21507     +115     
==========================================
+ Hits        14989    15089     +100     
- Misses       6403     6418      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kimhanbeom
Copy link
Copy Markdown
Contributor Author

@sehkone
Could you please review the current pull request?

@sophie-cluml
Copy link
Copy Markdown
Contributor

I think this PR suits our need.

Comment thread src/migration.rs Outdated
Version::parse(&ver).context("cannot parse VERSION")
}

fn migrate_0_34_0_to_0_36_alpha_1(store: &super::Store) -> Result<()> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be migrate_0_34_0_to_0_36 according to the guideline.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/migration.rs Outdated
migrate_0_36_alpha_1_account(store)
}

fn migrate_0_36_alpha_1_account(store: &super::Store) -> Result<()> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Accordingly, this should be migrate_0_36_account without alpha_1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/migration.rs Outdated
}

#[test]
fn migrate_0_36_alpha_1_account() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

alpha_1 needs to be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread CHANGELOG.md Outdated

### Changed

- Added `Account::customer_ids` field to store the customer id the user belongs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be better to add 'that' between 'customer id' and 'the user' for clarity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/migration/migration_structures.rs Outdated
}

#[derive(Clone, Deserialize, Serialize, PartialEq, Debug)]
pub struct AccountBeforeV35 {
Copy link
Copy Markdown
Contributor

@sehkone sehkone Mar 12, 2025

Choose a reason for hiding this comment

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

@kimhanbeom @sophie-cluml,

Since the new Account is introduced in 0.36.0, I think the old one should be named AccountBeforeV36. I wonder if the current code follows this way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have renamed AccountBeforeV35 to AccountBeforeV36.

@msk
Copy link
Copy Markdown
Contributor

msk commented Mar 15, 2025

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new customer_ids field to the Account struct and handles the associated database migrations. The changes seem well-structured, but there are a few areas that could be improved for better maintainability and correctness.

Summary of Findings

  • Migration Logic: The migration logic in src/migration.rs appears complex. Consider simplifying the migration steps or adding more detailed comments to explain the process. Ensure that the migration handles edge cases and potential data inconsistencies gracefully.
  • Data Type Consistency: The customer_ids field is defined as Option<Vec<u32>>. Ensure that the choice of u32 is appropriate for all customer IDs and that the Option type is handled consistently throughout the codebase to avoid unexpected None values.
  • Testing: While tests are added, ensure that the migration tests cover a wide range of scenarios, including accounts with and without existing customer IDs. Consider adding tests to verify the migration's behavior when encountering invalid or unexpected data.

Merge Readiness

The pull request introduces important database schema changes. While the code appears functional, the migration logic needs careful review and thorough testing to ensure data integrity. I recommend addressing the identified issues and adding more comprehensive tests before merging. I am unable to approve this pull request, and other reviewers should also carefully examine the migration logic and tests before approving.

Comment thread src/migration.rs
Comment thread src/migration.rs
Comment thread src/migration.rs
Comment thread src/migration.rs
@msk msk merged commit 6ea7d5e into aicers:main Mar 15, 2025
6 checks passed
@kimhanbeom kimhanbeom deleted the david/issue-408 branch March 18, 2025 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a field for customer id in Account

4 participants