Skip to content

refactor(ILookup): add GetItemsAsync extension method #4979

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

Merged
merged 13 commits into from
Dec 28, 2024
Merged

Conversation

ArgoZhang
Copy link
Collaborator

@ArgoZhang ArgoZhang commented Dec 28, 2024

add GetItemsAsync extension method

Summary of the changes (Less than 80 chars)

简单描述你更改了什么, 不超过80个字符;如果有关联 Issue 请在下方填写相关编号

Description

fixes #4978

Regression?

  • Yes
  • No

[If yes, specify the version the behavior has regressed from]

[是否影响老版本]

Risk

  • High
  • Medium
  • Low

[Justify the selection above]

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Introduce the GetItemsAsync extension method for ILookup.

New Features:

  • Introduce the GetItemsAsync extension method for ILookup to retrieve lookup items based on a key and associated data.

Tests:

  • Add unit tests for the new Select Lookup feature.

Copy link
Contributor

sourcery-ai bot commented Dec 28, 2024

Reviewer's Guide by Sourcery

This pull request introduces the GetItemsAsync extension method for the ILookup interface. This change simplifies the process of retrieving lookup items by consolidating the logic into a single method. It also improves code readability and reduces redundancy across components that use lookups.

Sequence diagram for GetItemsAsync extension method

sequenceDiagram
    participant Component as Component implementing ILookup
    participant Extension as ILooupExtensions
    participant Service as ILookupService

    Component->>Extension: GetItemsAsync(service, key, data)
    alt Lookup property exists
        Extension-->>Component: Return Lookup property
    else Lookup is null
        Extension->>Service: GetItemsByKey(key, data)
        alt Sync lookup exists
            Service-->>Extension: Return sync lookup
        else Sync lookup is null
            Extension->>Service: GetItemsByKeyAsync(key, data)
            Service-->>Extension: Return async lookup
        end
        Extension-->>Component: Return lookup items
    end
Loading

File-Level Changes

Change Details Files
Added GetItemsAsync extension method to the ILookup interface.
  • Created the GetItemsAsync extension method to retrieve lookup items based on a key and data object.
  • Implemented logic to handle both synchronous and asynchronous lookup retrieval.
  • Added handling for cases where the lookup key is null or empty.
src/BootstrapBlazor/Extensions/ILooupExtensions.cs
Refactored components to use the new GetItemsAsync extension method.
  • Replaced existing lookup retrieval logic with calls to the GetItemsAsync extension method.
  • Simplified the code by removing redundant lookup retrieval implementations.
  • Improved code consistency across components.
src/BootstrapBlazor/Components/Table/LookupContent.cs
src/BootstrapBlazor/Components/Filters/LookupFilter.razor.cs
src/BootstrapBlazor/Components/Select/Select.razor.cs
src/BootstrapBlazor/Components/Display/Display.razor.cs
Implemented the ILookup interface in the Select component.
  • Added the ILookup interface to the Select component.
  • Implemented the Lookup and LookupStringComparison properties of the ILookup interface.
  • Ensured that the Select component behaves consistently with other components that use the ILookup interface.
src/BootstrapBlazor/Components/Select/Select.razor.cs
Added unit tests for the GetItemsAsync extension method and the updated Select component.
  • Created unit tests to verify the functionality of the GetItemsAsync extension method.
  • Added tests to ensure that the Select component correctly uses the GetItemsAsync method.
  • Verified the behavior of the Lookup and LookupStringComparison properties in the Select component.
test/UnitTest/Components/SelectTest.cs
Removed the ILookupServiceExtensions.cs file.
  • Deleted the ILookupServiceExtensions.cs file as its functionality is now included in the ILooupExtensions.cs file.
  • Removed any references to the ILookupServiceExtensions.cs file.
src/BootstrapBlazor/Extensions/ILookupServiceExtensions.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#4978 Add GetItemsAsync extension method to ILookup

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added the enhancement New feature or request label Dec 28, 2024
@bb-auto bb-auto bot added this to the v9.0.0 milestone Dec 28, 2024
sourcery-ai[bot]
sourcery-ai bot previously approved these changes Dec 28, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ArgoZhang - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

codecov bot commented Dec 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1162f30) to head (b9275a5).
Report is 711 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #4979      +/-   ##
===========================================
+ Coverage   99.96%   100.00%   +0.03%     
===========================================
  Files         579       630      +51     
  Lines       24790     28070    +3280     
  Branches     3584      4025     +441     
===========================================
+ Hits        24781     28070    +3289     
+ Misses          4         0       -4     
+ Partials        5         0       -5     

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

@ArgoZhang ArgoZhang merged commit 4bc12ae into main Dec 28, 2024
3 checks passed
@ArgoZhang ArgoZhang deleted the refactor-lookup branch December 28, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor(ILookup): add GetItemsAsync extension method
1 participant