Skip to content

[+] Chusan events convert tool #143

New issue

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

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

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: v1-dev
Choose a base branch
from

Conversation

noarchwastaken
Copy link
Contributor

@noarchwastaken noarchwastaken commented May 27, 2025

It takes option folders and convert the events to database migration scripts.

好的,这是翻译成中文的 pull request 摘要:

Sourcery 提供的摘要

添加一个 CLI 工具,用于将 Chusan 活动 XML 文件转换为 chusan_game_event 的 SQL 迁移脚本

新功能:

  • 添加 chusan-events.py 以遍历给定目录,解析 Event.xml 文件,并提取活动 id 和类型
  • 生成具有固定开始/结束日期和启用标志的多行 SQL INSERT 语句
  • 包括针对缺少 XML 元素或解析失败的基本错误处理
Original summary in English

Summary by Sourcery

Add a CLI tool to convert Chusan event XML files into SQL migration scripts for chusan_game_event

New Features:

  • Add chusan-events.py to traverse given directories, parse Event.xml files, and extract event id and type
  • Generate multiline SQL INSERT statements with fixed start/end dates and enable flag
  • Include basic error handling for missing XML elements or parse failures

Copy link
Contributor

sourcery-ai bot commented May 27, 2025

## 审查者指南

介绍了一个新的基于 Python 的 CLI 工具,该工具扫描给定的目录以查找事件 XML,提取事件 ID 和类型,并组装一个多行 SQL 迁移脚本。

#### 事件 XML 到 SQL 转换过程的序列图

```mermaid
sequenceDiagram
    actor User
    participant Script as "chusan-events.py"
    participant FileSystem as "File System"

    User->>Script: Execute with <dir_name>...
    Script->>FileSystem: For each <dir_name>:
    Script->>FileSystem:   Access <dir_name>/event/
    Script->>FileSystem:   List subdirectories in event/
    loop For each event subdirectory
        Script->>FileSystem: Access Event.xml
        alt Event.xml exists
            Script->>FileSystem: Read Event.xml
            Script->>Script: Parse XML, extract id & type (extract_id_type function)
            Script->>Script: Format SQL INSERT value string
        else Event.xml does not exist
            Script->>Script: Skip directory
        end
    end
    Script->>User: Print combined SQL INSERT statement

chusan_game_event 表的实体关系图

erDiagram
    chusan_game_event {
        int id PK "事件 ID"
        int type "事件类型"
        datetime start_date "开始日期"
        datetime end_date "结束日期"
        boolean enable "是否启用"
    }
Loading

文件级别更改

Change Details Files
添加了 event-to-SQL 转换工具
  • 定义了 extract_id_type() 来解析 XML 并检索 id 和 type
  • 循环遍历输入目录以定位事件子文件夹和 Event.xml 文件
  • 构建并将 INSERT 语句聚合为单个多行 SQL 字符串
  • 包括命令行用法检查和简单的错误日志记录
tools/chusan-events.py

提示和命令

与 Sourcery 互动

  • 触发新的审查: 在 pull request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 通过回复审查评论,要求 Sourcery 从审查评论创建一个 issue。您也可以回复审查评论并使用 @sourcery-ai issue 从中创建一个 issue。
  • 生成 pull request 标题: 在 pull request 标题中的任何位置写入 @sourcery-ai 以随时生成标题。您也可以在 pull request 上评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中的任何位置写入 @sourcery-ai summary 以随时在您想要的位置生成 PR 摘要。您也可以在 pull request 上评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成审查者指南: 在 pull request 上评论 @sourcery-ai guide 以随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。如果您已经处理了所有评论并且不想再看到它们,这将非常有用。
  • 驳回所有 Sourcery 审查: 在 pull request 上评论 @sourcery-ai dismiss 以驳回所有现有的 Sourcery 审查。如果您想重新开始新的审查,这将特别有用 - 不要忘记评论 @sourcery-ai review 以触发新的审查!

自定义您的体验

访问您的 仪表板 以:

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

获得帮助

```
Original review guide in English

Reviewer's Guide

Introduces a new Python-based CLI tool that scans given directories for event XMLs, extracts event IDs and types, and assembles a multi-line SQL migration script.

Sequence Diagram for Event XML to SQL Conversion Process

sequenceDiagram
    actor User
    participant Script as "chusan-events.py"
    participant FileSystem as "File System"

    User->>Script: Execute with <dir_name>...
    Script->>FileSystem: For each <dir_name>:
    Script->>FileSystem:   Access <dir_name>/event/
    Script->>FileSystem:   List subdirectories in event/
    loop For each event subdirectory
        Script->>FileSystem: Access Event.xml
        alt Event.xml exists
            Script->>FileSystem: Read Event.xml
            Script->>Script: Parse XML, extract id & type (extract_id_type function)
            Script->>Script: Format SQL INSERT value string
        else Event.xml does not exist
            Script->>Script: Skip directory
        end
    end
    Script->>User: Print combined SQL INSERT statement
Loading

Entity Relationship Diagram for the chusan_game_event Table

erDiagram
    chusan_game_event {
        int id PK "Event ID"
        int type "Event Type"
        datetime start_date "Start Date"
        datetime end_date "End Date"
        boolean enable "Is Enabled"
    }
Loading

File-Level Changes

Change Details Files
Added event-to-SQL conversion tool
  • Defined extract_id_type() to parse XML and retrieve id and type
  • Looped through input directories to locate event subfolders and Event.xml files
  • Constructed and aggregated INSERT statements into a single multi-line SQL string
  • Included command-line usage checks and simple error logging
tools/chusan-events.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. 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

@noarchwastaken noarchwastaken force-pushed the chusan_events_script branch from 3afe88f to 4d1b9af Compare May 27, 2025 08:56
@noarchwastaken noarchwastaken force-pushed the chusan_events_script branch from 4d1b9af to 97ed4b6 Compare June 2, 2025 04:29
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.

1 participant