feat: add download-count sorting to plugin marketplace - #9570
Closed
Sisyphbaous-DT-Project wants to merge 1 commit into
Closed
feat: add download-count sorting to plugin marketplace#9570Sisyphbaous-DT-Project wants to merge 1 commit into
Sisyphbaous-DT-Project wants to merge 1 commit into
Conversation
为插件市场现有的前端本地排序补充下载量选项,复用已规范化的 download_count,不改变默认推荐顺序、后端接口和 OpenAPI。 新增稳定且不修改输入的下载量排序工具:支持升降序、未知值双向置底、非法值兜底及相同值原始顺序保留;接入市场排序控件并补齐中、英、俄三语文案。 新增 9 项专项单元测试,覆盖正常排序、零值、缺失与非法值、负数、数字字符串、小数、稳定性和输入不可变。验证通过 45 项 Dashboard Node 测试、额外性质检查、三语 JSON 校验、Vue 类型检查和生产构建。
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
marketPluginSort.mjs, you manually enforce stability via index tracking even though modern engines already provide stableArray.prototype.sort; consider removing the index plumbing to simplify the comparator and reduce per-item allocations. - The
normalizeDownloadCounthelper silently normalizes negatives to zero and treatsNaN/Infinity as unknown; if this is relying on backend invariants, it may be worth tightening the accepted input range or documenting this behavior near the function to avoid surprising ordering if backend data changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `marketPluginSort.mjs`, you manually enforce stability via index tracking even though modern engines already provide stable `Array.prototype.sort`; consider removing the index plumbing to simplify the comparator and reduce per-item allocations.
- The `normalizeDownloadCount` helper silently normalizes negatives to zero and treats `NaN`/Infinity as unknown; if this is relying on backend invariants, it may be worth tightening the accepted input range or documenting this behavior near the function to avoid surprising ordering if backend data changes.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
Author
|
The explicit index tie-breaker intentionally guarantees deterministic ordering, while the normalization behavior mirrors the existing marketplace store and is covered by focused tests, so we’ll keep the current implementation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation / 动机
The plugin marketplace already exposes and displays
download_count, but the marketplace sort menu does not provide a way to order plugins by downloads. Users must currently rely on the default recommendation order, stars, author, or update time when looking for widely used plugins.This change adds download-count sorting while preserving the existing default recommendation behavior and all existing sort modes.
Modifications / 改动点
sortMarketPluginsByDownloadsutility for frontend-local sorting.Downloadsoption to the marketplace sort control.zh-CN,en-US, andru-RU.The implementation intentionally keeps sorting on the frontend and does not change backend routes, OpenAPI definitions, generated API clients, dependencies, or the default recommendation order.
Screenshots or Test Results / 运行截图或测试结果
Verification Steps
Additional checks completed:
Manual UI Verification
Downloadsin the marketplace sort menu and verify descending order by default.Checklist / 检查清单
Summary by Sourcery
Add download-count-based sorting to the plugin marketplace while keeping existing sort modes and behavior unchanged.
New Features:
Enhancements:
Tests: