Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

🐛 修复群组中插件默认状态 #1810

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

HibiKier
Copy link
Owner

@HibiKier HibiKier commented Dec 30, 2024

Summary by Sourcery

Bug 修复:

  • 修复了插件在组中默认状态未正确反映的问题。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Fixed a bug where the default status of plugins was not correctly reflected in groups.

Copy link
Contributor

sourcery-ai bot commented Dec 30, 2024

审阅者指南 by Sourcery

这个拉取请求修复了群组中插件的默认状态。它在 GroupConsole 模型中引入了一个新的方法 convert_module_format,用于在插件模块名称列表和格式化字符串之间进行转换。同时更新了 GroupConsole 模型的 createget_or_createupdate_or_create 方法,使用这个新方法正确设置 block_pluginblock_task 字段。此外,还修正了插件开关命令中重复的快捷方式定义。

插件状态初始化序列图

sequenceDiagram
    participant GC as GroupConsole
    participant PI as PluginInfo
    participant TI as TaskInfo
    Note over GC: Group Creation/Update
    GC->>TI: Get tasks with default_status=False
    TI-->>GC: Return task modules
    GC->>GC: Convert task modules to format
    GC->>PI: Get plugins with default_status=False
    PI-->>GC: Return plugin modules
    GC->>GC: Convert plugin modules to format
    GC->>GC: Save block_plugin and block_task
Loading

GroupConsole 模型变更类图

classDiagram
    class GroupConsole {
        +String block_task
        +String block_plugin
        +static format(name: str) str
        +static convert_module_format(data: str|list[str]) str|list[str]
        +static create(using_db, **kwargs)
        +static get_or_create(using_db, **kwargs)
        +static update_or_create(using_db, **kwargs)
    }
    note for GroupConsole "添加了新的 format 和 convert_module_format 方法
更新了 create 方法以处理插件默认状态"
Loading

文件级变更

变更 详情 文件
GroupConsole 模型中引入新的 convert_module_format 方法,用于处理模块列表和格式化字符串之间的转换。
  • GroupConsole 模型添加 formatconvert_module_format 方法。
  • convert_module_format 方法使用 '<' 作为分隔符和逗号,在字符串列表和格式化字符串之间进行转换。
  • format 方法通过在插件名称周围添加 '<name,' 来格式化单个插件名称。
zhenxun/models/group_console.py
更新 GroupConsole 模型中的 create、get_or_create 和 update_or_create 方法,使用新的 convert_module_format 方法。
  • 修改 createget_or_createupdate_or_create 方法,使用 convert_module_format 方法设置 block_pluginblock_task 字段。
  • 添加从数据库检索插件和任务默认状态的逻辑,并使用 convert_module_format 方法将其转换为正确格式。
zhenxun/models/group_console.py
修正插件开关命令中重复的快捷方式定义。
  • 删除使用 -df 标志关闭插件的重复快捷方式定义。
  • 更正剩余快捷方式定义的正则表达式和参数。
zhenxun/builtin_plugins/admin/plugin_switch/command.py

提示和命令

与 Sourcery 交互

  • 触发新的审阅: 在拉取请求中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub 问题: 通过回复评论,要求 Sourcery 创建一个问题。
  • 生成拉取请求标题: 在拉取请求标题的任何位置写 @sourcery-ai 以随时生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任何位置写 @sourcery-ai summary 以随时生成 PR 摘要。您还可以使用此命令指定摘要应插入的位置。

自定义您的体验

访问您的仪表板以:

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

获取帮助

Original review guide in English

Reviewer's Guide by Sourcery

This pull request fixes the default status of plugins in groups. It introduces a new method convert_module_format in the GroupConsole model to convert between a list of plugin module names and a formatted string. It also updates the create, get_or_create, and update_or_create methods of the GroupConsole model to use this new method to correctly set the block_plugin and block_task fields. Additionally, it corrects a duplicated shortcut definition in the plugin switch command.

Sequence diagram for plugin status initialization

sequenceDiagram
    participant GC as GroupConsole
    participant PI as PluginInfo
    participant TI as TaskInfo
    Note over GC: Group Creation/Update
    GC->>TI: Get tasks with default_status=False
    TI-->>GC: Return task modules
    GC->>GC: Convert task modules to format
    GC->>PI: Get plugins with default_status=False
    PI-->>GC: Return plugin modules
    GC->>GC: Convert plugin modules to format
    GC->>GC: Save block_plugin and block_task
Loading

Class diagram for GroupConsole model changes

classDiagram
    class GroupConsole {
        +String block_task
        +String block_plugin
        +static format(name: str) str
        +static convert_module_format(data: str|list[str]) str|list[str]
        +static create(using_db, **kwargs)
        +static get_or_create(using_db, **kwargs)
        +static update_or_create(using_db, **kwargs)
    }
    note for GroupConsole "Added new format and convert_module_format methods
Updated create methods to handle plugin default status"
Loading

File-Level Changes

Change Details Files
Introduced a new method convert_module_format to the GroupConsole model to handle the conversion between list of modules and formatted string.
  • Added format and convert_module_format methods to the GroupConsole model.
  • The convert_module_format method converts between a list of strings and a formatted string using '<' as separators and commas.
  • The format method formats individual plugin names by wrapping them in '<name,'.
zhenxun/models/group_console.py
Updated the create, get_or_create, and update_or_create methods in the GroupConsole model to use the new convert_module_format method.
  • Modified the create, get_or_create, and update_or_create methods to use the convert_module_format method for setting the block_plugin and block_task fields.
  • Added logic to retrieve default statuses of plugins and tasks from the database and convert them to the correct format using the convert_module_format method.
zhenxun/models/group_console.py
Corrected a duplicated shortcut definition in the plugin switch command.
  • Removed the duplicated shortcut definition for closing plugins with the -df flag.
  • Corrected the regex and arguments for the remaining shortcut definition.
zhenxun/builtin_plugins/admin/plugin_switch/command.py

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

@AkashiCoin AkashiCoin added the bug Something isn't working label Dec 30, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

@HibiKier - 我已经审查了你的更改 - 以下是一些反馈:

整体评论

  • '关闭' 的正则匹配器重新排序是有意为之吗?这可能会改变首先匹配的模式 - 请确认这是你期望的行为变更。
以下是我在审查期间查看的内容
  • 🟢 一般性问题:一切看起来都很好
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

Sourcery 对开源项目是免费的 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English

Hey @HibiKier - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Was the reordering of the regex matchers for '关闭' intentional? This could change which pattern matches first - please confirm this was the desired behavior change.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@HibiKier HibiKier merged commit 91dce56 into main Dec 30, 2024
3 checks passed
@HibiKier HibiKier deleted the bugfix/group-default-plugin-status branch December 30, 2024 08:44
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants