Skip to content

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Oct 24, 2025

…packages

Implemented two new search filter configurations:

  1. searchExcludeDeprecated - Filter deprecated packages from search results

    • Default: true (deprecated packages are excluded by default)
    • Can be disabled by setting to false
    • Controlled by env: CNPMCORE_CONFIG_SEARCH_EXCLUDE_DEPRECATED
  2. searchPackageMinAge - Filter newly published packages

    • Default: empty string (no filter applied)
    • Supports time format: '2w' (weeks), '14d' (days), '336h' (hours)
    • Controlled by env: CNPMCORE_CONFIG_SEARCH_PACKAGE_MIN_AGE

Changes:

  • Added deprecated field to SearchMappingType and sync it to Elasticsearch
  • Added _buildFilterQueries() method to build Elasticsearch filter conditions
  • Added _parseTimeString() helper to parse time strings (h/d/w format)
  • Added comprehensive unit tests for the new filter functionality

Closes #858

🤖 Generated with Claude Code

…packages

Implemented two new search filter configurations:

1. `searchExcludeDeprecated` - Filter deprecated packages from search results
   - Default: true (deprecated packages are excluded by default)
   - Can be disabled by setting to false
   - Controlled by env: CNPMCORE_CONFIG_SEARCH_EXCLUDE_DEPRECATED

2. `searchPackageMinAge` - Filter newly published packages
   - Default: empty string (no filter applied)
   - Supports time format: '2w' (weeks), '14d' (days), '336h' (hours)
   - Controlled by env: CNPMCORE_CONFIG_SEARCH_PACKAGE_MIN_AGE

Changes:
- Added `deprecated` field to SearchMappingType and sync it to Elasticsearch
- Added `_buildFilterQueries()` method to build Elasticsearch filter conditions
- Added `_parseTimeString()` helper to parse time strings (h/d/w format)
- Added comprehensive unit tests for the new filter functionality

Closes #858

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@fengmk2 fengmk2 requested a review from Copilot October 24, 2025 08:49
@graphite-app
Copy link

graphite-app bot commented Oct 24, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • MQ - adds this PR to the back of the merge queue
  • Hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/implement-issue-858-011CURYUu9i46HHcFVRQ5fFV

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds configurable search filters to exclude deprecated packages and newly published packages from search results. The implementation adds Elasticsearch query filters based on two new configuration options: searchExcludeDeprecated (defaults to true) and searchPackageMinAge (supports time format strings like '2w', '14d', '336h').

Key Changes:

  • Added deprecated field to Elasticsearch search mapping and sync logic
  • Implemented _buildFilterQueries() and _parseTimeString() helper methods in PackageSearchService
  • Added comprehensive test coverage for both filter configurations

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
config/config.default.ts Added two new configuration options with environment variable bindings
app/port/config.ts Added TypeScript interface definitions for the new config options with JSDoc
app/repository/SearchRepository.ts Extended SearchMappingType to include 'deprecated' field
app/core/service/PackageSearchService.ts Implemented filter query building logic and time string parsing utility
test/port/controller/package/SearchPackageController.test.ts Added comprehensive test cases for both filter configurations
}

private _buildFilterQueries() {
// oxlint-disable-next-line typescript-eslint/no-explicit-any
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

The oxlint-disable comment uses an incorrect rule name. According to the .oxlintrc.json configuration, the correct rule name should be @typescript-eslint/no-explicit-any (with @ prefix), not typescript-eslint/no-explicit-any.

Suggested change
// oxlint-disable-next-line typescript-eslint/no-explicit-any
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
Copilot uses AI. Check for mistakes.
Comment on lines +127 to +128
// 最新版本的 deprecated 信息
deprecated: latestManifest?.deprecated as string | undefined,
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

The comment is in Chinese while the codebase appears to use English for comments elsewhere in this file (lines 131, 348-353). Consider translating to English: '// Latest version deprecated information' to maintain consistency.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants