Skip to content

feat: 标签统计增加过滤范围 --story=140191570 - #1028

Merged
guohelu merged 2 commits into
TencentBlueKing:developfrom
guohelu:develop_261117
Nov 17, 2026
Merged

guohelu merged 2 commits into
TencentBlueKing:developfrom
guohelu:develop_261117

Conversation

@guohelu

@guohelu guohelu commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🔎 AI 代码审查

📌 9ba74b7123c9 · 🧪 未执行测试

Warning

⚠️ 有 1 项问题需要处理或确认

请优先查看下方待处理问题。

🆕 新增 🔴 仍存在 ✅ 已修复 ❔ 待确认
0 1 1 0

🚩 待处理问题

🔴 仍存在 · scope_type/scope_value 未做成对校验,单边传入时作用域过滤被静默忽略

📍 bkflow/apigw/serializers/label.py:40 · 🏷️ F-c93a79d575c3 · P2

当前快照中两个 Serializer 仍未新增 validate()/字段级成对校验:bkflow/apigw/serializers/label.py 的 LabelRefCountSerializer 只有 validate_label_ids,scope_type/scope_value 仍为 required=False;bkflow/task/serializers.py 的 LabelRefSerializer 同样只有两个可选字段。调用端仍是 `scope_type is not None and scope_value is not None` 才过滤(get_label_ref_count.py:47-48、task/views.py:258-260、task.py:71-72),单边传入仍会静默退化为全空间统计且无报错。问题仍存在。

🧩 当前代码证据

bkflow/apigw/serializers/label.py:40

    scope_type = serializers.CharField(help_text=_("流程范围类型,传入时仅统计该作用域下的引用"), required=False)

🔁 历史复核

✅ 已修复(静态代码确认) · get_task_label_ref_count 改为 data 传参后未同步既有单测,engine 测试将失败

📍 bkflow/contrib/api/collections/task.py:76 · 🏷️ F-c91b1084b937 · P2

当前快照 tests/engine/utils/test_client.py:259-264 已更新断言为 url='http://task\.space1/task/get\_task\_label\_ref\_count/&\#x27;、data=\{&\#x27;space\_id&\#x27;: 1, 'label_ids': '1,2'},与 TaskComponentClient.get_task_label_ref_count 现在构造的 data 一致(task.py:70-77)。原断言失败点已修复,不再导致 engine 单测红。

🧩 当前代码证据

tests/engine/utils/test_client.py:263

            data={"space_id": 1, "label_ids": "1,2"},

📎 审查边界

未运行任何测试/构建,结论均基于静态源码与本次 diff。`bkflow/apigw/management/commands/data/api-resources.yml` 与 `bkflow/apigw/docs/apigw-docs.zip` 被过滤,无法核对 get_label_ref_count 新增可选 query 参数 scope_type/scope_value 是否需要同步网关资源定义/文档。scope 过滤在 all_resource(interface/engine 分库)部署下依赖模板 scope 正确继承到任务:已沿 template/views/template.py create_task 传播链路(scope_type/scope_value 由 template 写入 create_task_data)确认代码路径,但未做运行时验证,任务存量数据(NULL scope)是否与模板 scope 一致会影响按 scope 统计的 task_count,需环境验证。frontend/package-lock.json 等被过滤,未核对前端调用方是否传入 scope。

📋 审查范围与验证说明

仅辅助人工审查;未执行测试,也不代表已满足合入或发布条件。

快照过滤了 13 个大文件、链接或工具配置文件;diff 仍包含其修改。


💡 本报告辅助人工审查,结论绑定上述提交。

@github-actions

Copy link
Copy Markdown

🔁 AI 代码审查复核

📌 9ba74b7123c9 · 🧪 未执行测试

对上轮审查的逐项回复:

🔴 仍存在 · scope_type/scope_value 未做成对校验,单边传入时作用域过滤被静默忽略

📍 bkflow/apigw/serializers/label.py:40 · 🏷️ F-c93a79d575c3 · P2

当前快照中两个 Serializer 仍未新增 validate()/字段级成对校验:bkflow/apigw/serializers/label.py 的 LabelRefCountSerializer 只有 validate_label_ids,scope_type/scope_value 仍为 required=False;bkflow/task/serializers.py 的 LabelRefSerializer 同样只有两个可选字段。调用端仍是 `scope_type is not None and scope_value is not None` 才过滤(get_label_ref_count.py:47-48、task/views.py:258-260、task.py:71-72),单边传入仍会静默退化为全空间统计且无报错。问题仍存在。

🧩 当前代码证据

bkflow/apigw/serializers/label.py:40

    scope_type = serializers.CharField(help_text=_("流程范围类型,传入时仅统计该作用域下的引用"), required=False)
✅ 已修复(静态代码确认) · get_task_label_ref_count 改为 data 传参后未同步既有单测,engine 测试将失败

📍 bkflow/contrib/api/collections/task.py:76 · 🏷️ F-c91b1084b937 · P2

当前快照 tests/engine/utils/test_client.py:259-264 已更新断言为 url='http://task\.space1/task/get\_task\_label\_ref\_count/&\#x27;、data=\{&\#x27;space\_id&\#x27;: 1, 'label_ids': '1,2'},与 TaskComponentClient.get_task_label_ref_count 现在构造的 data 一致(task.py:70-77)。原断言失败点已修复,不再导致 engine 单测红。

🧩 当前代码证据

tests/engine/utils/test_client.py:263

            data={"space_id": 1, "label_ids": "1,2"},

以上为静态代码复核,未运行测试;无法确认项继续保留,不自动关闭讨论。

@guohelu
guohelu merged commit b1bade0 into TencentBlueKing:develop Nov 17, 2026
10 checks passed
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.54%. Comparing base (6f4a239) to head (9ba74b7).
⚠️ Report is 174 commits behind head on develop.

Files with missing lines Patch % Lines
bkflow/apigw/views/get_label_ref_count.py 75.00% 2 Missing ⚠️
bkflow/contrib/api/collections/task.py 60.00% 2 Missing ⚠️
bkflow/task/views.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1028      +/-   ##
===========================================
+ Coverage    84.24%   86.54%   +2.30%     
===========================================
  Files          331      377      +46     
  Lines        21760    25315    +3555     
===========================================
+ Hits         18332    21910    +3578     
+ Misses        3428     3405      -23     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants