Skip to content

modify: set assignee to creator when export workflow is rejected#592

Merged
iwanghc merged 1 commit intomainfrom
commit/dashboard-v2
Apr 10, 2026
Merged

modify: set assignee to creator when export workflow is rejected#592
iwanghc merged 1 commit intomainfrom
commit/dashboard-v2

Conversation

@winfredLIN
Copy link
Copy Markdown
Collaborator

@winfredLIN winfredLIN commented Apr 9, 2026

User description

关联的 issue

https://github.com/actiontech/sqle-ee/issues/2682

link https://github.com/actiontech/sqle-ee/pull/2688

描述你的变更

  • 为实现dashboard v2 版本待我处理工单的续期,将被驳回的工单,从展示逻辑上调整为指向创建者,不调整工单流转流程

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 修改导出流程展示逻辑:驳回状态不显示当前步骤处理人

  • 更新SQL查询:驳回时将当前步骤指派用户改为创建者

  • 优化数据库字符串扫描错误处理,增加nil及类型判断


Diagram Walkthrough

flowchart LR
  A["检测工作流状态"] -->|非结束状态| B["展示当前步骤指派"]
  A -->|结束/驳回状态| C["隐藏当前步骤指派"]
  D["SQL查询逻辑更新"] --> C
  E["字符串扫描优化"] --> D
Loading

File Walkthrough

Relevant files
Enhancement
data_export_workflow.go
更新服务层步骤指派逻辑                                                                                           

internal/dms/service/data_export_workflow.go

  • 修改步骤指派展示条件:当状态非结束时显示当前处理人
  • 添加注释说明逻辑:结束状态不展示当前步骤操作人
+4/-3     
workflow.go
改进SQL查询及当前步骤数据处理                                                                                 

internal/dms/storage/workflow.go

  • 更新SQL查询逻辑:驳回状态返回创建者UID
  • 修改过滤条件保障驳回工单正确展示
  • 调整当前步骤数据设置,确保数组容量足够
+24/-6   
Bug fix
model.go
优化数据库字符串扫描处理                                                                                         

internal/dms/storage/model/model.go

  • 增加对nil值的检测,防止空指针错误
  • 支持多种类型转换,提高字符串扫描可靠性
+12/-1   

@winfredLIN winfredLIN self-assigned this Apr 9, 2026
@actiontech-bot actiontech-bot requested review from iwanghc and removed request for iwanghc April 9, 2026 08:05
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
增加数组边界检查

建议在直接访问数组元素前,先验证数组长度是否足够,防止出现数组越界导致的panic问题。请检查 w.WorkflowRecord.WorkflowSteps
数组是否包含足够的元素。这样可以提高代码的健壮性和容错能力。

internal/dms/service/data_export_workflow.go [150-152]

-if w.Status != string(dmsV1.StatusFinish) {
+if w.Status != string(dmsV1.StatusFinish) && len(w.WorkflowRecord.WorkflowSteps) >= int(w.WorkflowRecord.CurrentWorkflowStepId) {
     ret[i].CurrentStepAssigneeUsers = convertBizUidWithName(d.UserUsecase.GetBizUserIncludeDeletedWithNameByUids(ctx, w.WorkflowRecord.WorkflowSteps[w.WorkflowRecord.CurrentWorkflowStepId-1].Assignees))
 }
Suggestion importance[1-10]: 7

__

Why: The suggestion increases robustness by adding a boundary check for w.WorkflowRecord.WorkflowSteps to avoid potential panic. It addresses a potential runtime error, although it is a safety improvement rather than a critical bug fix.

Medium
General
清晰化索引计算逻辑

建议对 result.CurrentWorkflowStepId
为0的情况进行更明确的处理逻辑,避免使用冗余的条件判断。通过将索引计算拆分处理,可以让代码逻辑更清晰,易于后续维护和阅读。

internal/dms/storage/workflow.go [577-601]

 if result.CurrentWorkflowStepId > 0 || result.Status == "rejected" {
-    currentStepIndex := int64(result.CurrentWorkflowStepId) - 1
-    if currentStepIndex < 0 {
+    var currentStepIndex int64
+    if result.CurrentWorkflowStepId > 0 {
+        currentStepIndex = int64(result.CurrentWorkflowStepId) - 1
+    } else {
         currentStepIndex = 0
     }
     // Ensure WorkflowSteps has enough capacity
     if len(workflow.WorkflowRecord.WorkflowSteps) <= int(currentStepIndex) {
         newSteps := make([]*biz.WorkflowStep, currentStepIndex+1)
         copy(newSteps, workflow.WorkflowRecord.WorkflowSteps)
         for i := len(workflow.WorkflowRecord.WorkflowSteps); i <= int(currentStepIndex); i++ {
             newSteps[i] = &biz.WorkflowStep{
                 StepId:            uint64(i + 1),
                 WorkflowRecordUid: result.WorkflowRecordUID,
                 Assignees:         []string{},
             }
         }
         workflow.WorkflowRecord.WorkflowSteps = newSteps
     }
     workflow.WorkflowRecord.WorkflowSteps[currentStepIndex] = &biz.WorkflowStep{
         StepId:            uint64(currentStepIndex + 1),
         WorkflowRecordUid: result.WorkflowRecordUID,
         State:             result.CurrentStepState,
         Assignees:         result.CurrentStepAssigneeUserIDList,
     }
 }
Suggestion importance[1-10]: 5

__

Why: The code change refactors the index calculation for clarity by explicitly handling the zero case, making the logic more readable. However, its functional impact is minor as it achieves similar behavior to the original logic.

Low

@iwanghc iwanghc merged commit 3e96b9e into main Apr 10, 2026
1 check passed
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