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: sync block #700

Merged
merged 2 commits into from
Jun 25, 2024
Merged

fix: sync block #700

merged 2 commits into from
Jun 25, 2024

Conversation

elrrrrrrr
Copy link
Member

@elrrrrrrr elrrrrrrr commented Jun 25, 2024

remove es index when the target pkg has been blocked or deleted.

  1. ⚓ update SyncESPackage logic for event register
  2. ♻️ do the block check when syncPackage

包删除或被 block 时,es 索引同步删除

  1. ⚓ 修改 SyncESPackage 逻辑,更新事件注册
  2. ♻️ syncPackage 时,重新判断包是否被 block,用于清理

Summary by CodeRabbit

  • New Features

    • Introduced event types PACKAGE_BLOCKED and PACKAGE_UNBLOCKED for better package management.
  • Bug Fixes

    • Improved logic to handle package blocks before syncing, ensuring smoother operations.
  • Tests

    • Added test scenarios to cover new package blocking and unblocking features, enhancing reliability.

@elrrrrrrr elrrrrrrr added the bug Something isn't working label Jun 25, 2024
@elrrrrrrr elrrrrrrr requested review from fengmk2 and Beace June 25, 2024 11:42
Copy link
Contributor

coderabbitai bot commented Jun 25, 2024

Walkthrough

The recent changes introduce new event types PACKAGE_BLOCKED and PACKAGE_UNBLOCKED in the event handling system, particularly in SyncESPackage.ts. Additionally, PackageSearchService now includes a repository to manage package version blocks. Testing has also been enhanced to ensure blocked packages can be handled appropriately through the new services.

Changes

Files / Paths Change Summary
app/core/event/SyncESPackage.ts Added new event types PACKAGE_BLOCKED, PACKAGE_UNBLOCKED, updated event decorations for PackageUnpublished, PackageVersionAdded classes.
app/core/service/PackageSearchService.ts Injected PackageVersionBlockRepository, added logic to handle package blocks before syncing.
test/repository/SearchRepository.test.ts Included PackageManagerService, TestUtil, PackageSearchService, added test case for clearing a blocked package.

Poem

In the realm of codes, where bytes do speak,
Packages blocked and unblocked, a brand new tweak,
Events now dance to a different beat,
Searching is smarter, challenges we meet,
With tests in place, our paths align,
Ever forward, in brilliance we'll shine! ✨🐰


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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 571d265 and 69f800a.

Files selected for processing (3)
  • app/core/event/SyncESPackage.ts (3 hunks)
  • app/core/service/PackageSearchService.ts (3 hunks)
  • test/repository/SearchRepository.test.ts (2 hunks)
Additional comments not posted (7)
app/core/event/SyncESPackage.ts (3)

15-16: Added new event types for package blocking and unblocking.

These new constants PACKAGE_BLOCKED and PACKAGE_UNBLOCKED are well-defined and align with the PR's goal to handle blocked and unblocked packages.


35-35: Ensure proper event registration for PACKAGE_BLOCKED.

The @Event(PACKAGE_BLOCKED) decorator correctly associates the PackageUnpublished class with the blocked package event. This is crucial for the functionality described in the PR.


44-51: Updated event handling in PackageVersionAdded.

The class now handles multiple events including PACKAGE_META_CHANGED and PACKAGE_UNBLOCKED, which is consistent with the PR's description of enhancing event handling logic.

test/repository/SearchRepository.test.ts (2)

5-7: Added necessary imports for testing.

Imports for PackageManagerService, TestUtil, and PackageSearchService are added to support the new test scenario. This is essential for accessing the required functionalities in the tests.


116-180: New test scenario for clearing a blocked package.

This test ensures that the functionality for clearing a blocked package from the Elasticsearch index is working as expected. It uses mocks effectively to simulate the environment and checks the correct behavior through assertions.

app/core/service/PackageSearchService.ts (2)

11-11: Injection of PackageVersionBlockRepository.

The repository is correctly injected, enabling the service to access block information for packages. This is essential for the new functionality to remove blocked packages from Elasticsearch.

Also applies to: 26-27


44-49: Handling blocked packages during synchronization.

The service now checks if a package is blocked and removes it from Elasticsearch if it is. This is a crucial update for maintaining the integrity of the data in Elasticsearch, aligning with the PR's objectives.

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.81%. Comparing base (753e519) to head (69f800a).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #700      +/-   ##
==========================================
+ Coverage   96.80%   96.81%   +0.01%     
==========================================
  Files         181      181              
  Lines       18030    18002      -28     
  Branches     2336     2338       +2     
==========================================
- Hits        17454    17429      -25     
+ Misses        576      573       -3     

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

@@ -30,6 +32,7 @@ class SyncESPackage {
}

@Event(PACKAGE_UNPUBLISHED)
@Event(PACKAGE_BLOCKED)
Copy link
Member

Choose a reason for hiding this comment

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

原来还能叠加来写,学习了。

@fengmk2 fengmk2 merged commit ca6ce4e into master Jun 25, 2024
12 of 13 checks passed
@fengmk2 fengmk2 deleted the fix-sync-pkg branch June 25, 2024 12:28
@fengmk2 fengmk2 self-assigned this Jun 25, 2024
fengmk2 pushed a commit that referenced this pull request Jun 25, 2024
[skip ci]

## [3.61.5](v3.61.4...v3.61.5) (2024-06-25)

### Bug Fixes

* auto remove blocked package on sync process ([#700](#700)) ([ca6ce4e](ca6ce4e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants