Skip to content

fix(config): correct daily proxy status tags - #1758

Open
qiyinxi wants to merge 1 commit into
AUTO-MAS-Project:devfrom
qiyinxi:fix/proxy-tag-20261030
Open

qiyinxi wants to merge 1 commit into
AUTO-MAS-Project:devfrom
qiyinxi:fix/proxy-tag-20261030

Conversation

@qiyinxi

@qiyinxi qiyinxi commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

摘要

  • 修复当天运行中或运行失败后,用户标签误显示绿色「日常:已代理0次」的问题。

测试与验证

  • 自动化测试:D:\MAS\code\trees\proxytag\.venv\Scripts\python.exe -m pytest tests/models/test_shared_proxy_tag.py -q,修复前 1 failed / 1 passed,修复后 2 passed;ruff format、ruff check 和 scripts/changelog.py check 均通过。
  • 测试提交:无。回归测试 tests/models/test_shared_proxy_tag.py 按本地工作区规则写入公共 Git exclude,仅用于验证修复前红、修复后绿。
  • 环境与提交:Windows,Python 3.12.13;提交 6c3e8e11fb3b4b950d34fdbf0c335f325b8e6b84。
  • 未覆盖范围:未运行完整 pytest,也未覆盖真实游戏或模拟器流程;本次验证集中在共享标签逻辑。
  • 作者本机真实流程:N/A,纯后端标签逻辑修复。

Sourcery 摘要

修正没有成功代理运行记录的用户的每日代理状态标签。

错误修复:

  • 修正每日代理状态标签:只有当天至少有一次代理运行成功时,才会将用户标记为已完成代理运行。
  • 添加一条变更日志,记录此次代理状态标记修正。
Original summary in English

Summary by Sourcery

Correct daily proxy status tagging for users with no successful proxy runs.

Bug Fixes:

  • Correct daily proxy status tags so users are only marked as having completed proxy runs when at least one proxy run succeeded that day.
  • Add a changelog entry documenting the corrected proxy status labeling.

@sourcery-ai

sourcery-ai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
审阅者指南(小型 PR 中默认折叠)

审阅者指南

此 PR 修复了每日代理标签的分类逻辑:只有代理日期为当天且至少记录过一次代理,才会显示绿色“已代理N次”标签。这样可以避免失败或仍在进行中的运行因成功尝试次数为零而被标记为绿色“已代理0次”;此外还新增了一条更新日志。

每日代理状态分类流程图

flowchart TD
    A[读取 LastProxyDate 和 ProxyTimes] --> B{LastProxyDate 是今天吗?}
    B -->|否| C[返回橙色的未代理状态]
    B -->|是| D{ProxyTimes > 0 吗?}
    D -->|否| C
    D -->|是| E[返回绿色的已代理N次状态]
Loading

文件级变更

变更 详情 文件
仅当用户今天代理过且代理次数大于零时,才显示绿色的每日代理状态标签。
  • 在现有的当天日期检查旁增加 ProxyTimes > 0 条件。
  • 如果最后代理日期是今天,但没有记录成功的代理,则继续显示橙色的“未代理”标签。
app/models/config/shared.py
在项目更新日志中记录此错误修复。
  • 新增一条修复说明,指出当日没有成功代理时,用户被错误地标记为已代理。
changelog.d/fix-proxy-tag-20261030.fix.md

提示与命令

与 Sourcery 互动

  • 触发新一轮审阅: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 根据审阅评论创建 GitHub issue: 回复审阅评论,请 Sourcery 根据该评论创建 issue。你也可以在审阅评论下回复 @sourcery-ai issue 来创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,随时重新生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中你希望插入摘要的位置写入 @sourcery-ai summary,即可随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,随时重新生成摘要。
  • 生成审阅者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时重新生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论,不想再看到它们,这个命令会很有用。
  • 忽略所有 Sourcery 审阅: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审阅。如果你想从头开始新一轮审阅,这个命令尤其有用——别忘了评论 @sourcery-ai review 以触发新一轮审阅!

自定义使用体验

访问你的控制面板以:

  • 启用或禁用审阅功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、删除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR fixes daily proxy tag classification by requiring both a current-day proxy date and at least one recorded proxy, preventing failed or in-progress runs with zero successful attempts from receiving the green “已代理0次” label; it also adds a changelog entry.

Flow diagram for daily proxy status classification

flowchart TD
    A[Read LastProxyDate and ProxyTimes] --> B{LastProxyDate is today?}
    B -->|No| C[Return 未代理 with orange color]
    B -->|Yes| D{ProxyTimes > 0?}
    D -->|No| C
    D -->|Yes| E[Return 已代理N次 with green color]
Loading

File-Level Changes

Change Details Files
Restrict the green daily proxy status tag to users who both proxied today and have a positive proxy count.
  • Add a ProxyTimes > 0 guard alongside the existing current-day check.
  • Continue displaying the orange “not proxied” tag when the last proxy date is today but no successful proxy has been recorded.
app/models/config/shared.py
Document the bug fix in the project changelog.
  • Add a fix entry for users incorrectly marked as having proxied when no proxy succeeded that day.
changelog.d/fix-proxy-tag-20261030.fix.md

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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

@github-actions github-actions Bot added 专项: MAA 类型: 修复 按更新日志碎片自动设置 labels Oct 30, 2026

Copy link
Copy Markdown
Contributor

总体结论:修改后合并

  • 仓库与 PR:AUTO-MAS-Project/AUTO-MAS fix(config): correct daily proxy status tags #1758
  • head_sha:6c3e8e11fb3b4b950d34fdbf0c335f325b8e6b84
  • 目标分支:dev
  • base_tip_sha / merge_base_sha:75594fe1d3026593928953547cfd8c6f972bd400
  • 修复方向正确:当天日期不代表已经成功代理,增加次数大于零的条件能消除绿色「已代理0次」误报;合并前需将本次回归测试纳入仓库。

必须处理的问题

[规范 · P3] 已验证的回归测试未随修复提交

  • 位置: shared.py:217–224,对应缺失的 tests/models/test_shared_proxy_tag.py。
  • 现状: PR 正文说明已经编写该测试,并验证修复前失败、修复后通过,但将其放入公共 Git exclude;实际提交只有实现和更新日志。当前 tests/AGENTS.md:37–39 与开发文档明确要求稳定可复现的回归测试同 PR 保留。
  • 影响: 共享 helper 被多个专项复用,当前仓库没有覆盖本次零次误报的测试;CI 无法复核所述红绿用例,也无法在后续改动回退条件时守住行为。
  • 建议: 将已写的隔离回归测试纳入本 PR,固定时钟,覆盖当天零次、当天正次数及跨游戏日的标签结果,并保留自定义标签/时区的兼容断言。无需引入真实游戏或模拟器,也无需扩大实现改动。

审查范围与摘要

已核对日期/次数的写入、八个直接调用方及继承复用、虚拟标签到用户列表的展示链。该改动复用现有状态源,不新增跨层依赖、持久化契约或 I/O;标签派生无需新增遥测事件。未发现新增逻辑、性能或架构缺陷。本次为静态审查,作者所述本地测试未由本任务执行。

来自 dot

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

嗨——我发现了 1 个问题

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="app/models/config/shared.py" line_range="221" />
<code_context>
-    if config.Data.LastProxyDate.astimezone(tz).date() == datetime.now(tz=tz).date():
+    if (
+        config.Data.LastProxyDate.astimezone(tz).date() == datetime.now(tz=tz).date()
+        and config.Data.ProxyTimes > 0
+    ):
         return {"text": f"{label}:已代理{config.Data.ProxyTimes}次", "color": "green"}
</code_context>
<issue_to_address>
**Yesterday’s count appears as today’s success**

When the process stops after saving today’s `LastProxyDate` but before the `ProxyTimes` reset is committed, and yesterday’s count is positive, `_tag_proxy` sees today’s `LastProxyDate` and yesterday’s positive `ProxyTimes`, so it returns the green “已代理” tag even though no run succeeded today.

Commit the date update and counter reset atomically, or reset the counter before saving the new date.
</issue_to_address>

Sourcery 评估

等待批准。 请先处理 1 项发现。

阻塞性发现:app/models/config/shared.py:221


Sourcery 对开源项目免费——如果您喜欢我们的评审,请考虑分享 ✨
Original comment in English

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="app/models/config/shared.py" line_range="221" />
<code_context>
-    if config.Data.LastProxyDate.astimezone(tz).date() == datetime.now(tz=tz).date():
+    if (
+        config.Data.LastProxyDate.astimezone(tz).date() == datetime.now(tz=tz).date()
+        and config.Data.ProxyTimes > 0
+    ):
         return {"text": f"{label}:已代理{config.Data.ProxyTimes}次", "color": "green"}
</code_context>
<issue_to_address>
**Yesterday’s count appears as today’s success**

When the process stops after saving today’s `LastProxyDate` but before the `ProxyTimes` reset is committed, and yesterday’s count is positive, `_tag_proxy` sees today’s `LastProxyDate` and yesterday’s positive `ProxyTimes`, so it returns the green “已代理” tag even though no run succeeded today.

Commit the date update and counter reset atomically, or reset the counter before saving the new date.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: app/models/config/shared.py:221


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

if config.Data.LastProxyDate.astimezone(tz).date() == datetime.now(tz=tz).date():
if (
config.Data.LastProxyDate.astimezone(tz).date() == datetime.now(tz=tz).date()
and config.Data.ProxyTimes > 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 中等 · 昨日的计数被显示为今日成功

如果进程在保存今天的 LastProxyDate 后、提交 ProxyTimes 重置之前停止,并且昨日的计数大于零,_tag_proxy 会看到今天的 LastProxyDate 和昨日的正数 ProxyTimes,因此返回绿色的“已代理”标签,尽管今天并没有成功运行。

请以原子方式提交日期更新和计数器重置,或者在保存新日期之前重置计数器。

给 AI 智能体的提示
In `app/models/config/shared.py` at line 221:

**Yesterday’s count appears as today’s success**

When the process stops after saving today’s `LastProxyDate` but before the `ProxyTimes` reset is committed, and yesterday’s count is positive, `_tag_proxy` sees today’s `LastProxyDate` and yesterday’s positive `ProxyTimes`, so it returns the green “已代理” tag even though no run succeeded today.

Commit the date update and counter reset atomically, or reset the counter before saving the new date.
Original comment in English

🟡 Medium · Yesterday’s count appears as today’s success

When the process stops after saving today’s LastProxyDate but before the ProxyTimes reset is committed, and yesterday’s count is positive, _tag_proxy sees today’s LastProxyDate and yesterday’s positive ProxyTimes, so it returns the green “已代理” tag even though no run succeeded today.

Commit the date update and counter reset atomically, or reset the counter before saving the new date.

Prompt for AI agents
In `app/models/config/shared.py` at line 221:

**Yesterday’s count appears as today’s success**

When the process stops after saving today’s `LastProxyDate` but before the `ProxyTimes` reset is committed, and yesterday’s count is positive, `_tag_proxy` sees today’s `LastProxyDate` and yesterday’s positive `ProxyTimes`, so it returns the green “已代理” tag even though no run succeeded today.

Commit the date update and counter reset atomically, or reset the counter before saving the new date.

@qiyinxi

qiyinxi commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

所以现在到底交不交测试?我觉得还是只交核心吧。

Copy link
Copy Markdown
Contributor

按当前仓库规则,这类稳定、可隔离的回归测试需要随 PR 提交,不限于核心引擎测试。tests/AGENTS.md 的「核心最小回归」是 MaaFW 引擎测试的专门约束;后面的「Agent 规则」明确要求稳定 Bug 的回归测试同 PR 保留。

本次只需保留已经写好的、能守住零次误报的最小用例,不需要提交真实设备探针或扩大成整套专项测试。如果项目决定改回「只交核心测试」,应由维护者明确统一仓库与文档站规则;目前这条建议还不是已确认的规则变更,所以本次审查结论暂不变。

来自 dot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

专项: MAA 类型: 修复 按更新日志碎片自动设置

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants