Skip to content
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

在自动审核模式中,上线工单存在检测错误或警告时,并匹配auto_rwview_wrong参数时,工单状态应为自动审核不通过;在客户端JS脚本中增加脚本错误数的判断 #2692

Closed
wants to merge 21 commits into from

Conversation

peixubin
Copy link
Contributor

存在检测错误或警告时,拒绝提交,避免一些错误的SQL提交执行

@peixubin
Copy link
Contributor Author

"Codecov token not found. Please provide Codecov token with -t flag." 是什么意思?是不是构建脚本有问题

Copy link

codecov bot commented Jun 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.15%. Comparing base (52ce759) to head (059f172).
Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2692      +/-   ##
==========================================
+ Coverage   77.14%   77.15%   +0.01%     
==========================================
  Files         117      117              
  Lines       16174    16186      +12     
==========================================
+ Hits        12477    12489      +12     
  Misses       3697     3697              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@peixubin peixubin changed the title 存在检测错误或警告时,拒绝提交 在自动审核模式中,上线工单存在检测错误或警告时,并匹配auto_rwview_wrong参数时,工单状态应为自动审核不通过;在客户端JS脚本中增加脚本错误数的判断 Jul 1, 2024
@woshiyanghai
Copy link
Contributor

我是没有开启自动审核,sql检查如果有错误,或者警告,其实我认为应该可以提交,只是在审核区域不在展示,工单日志展示sql审核不通过。个人感觉稍微好一点? 比如有一个场景,研发写了很大一段sql准备让提工单。但是一直审核有错误,如果不让他提交,他找dba看的时候,还需要把sql发送dba,然后好像比较麻烦?

Copy link
Collaborator

@LeoQuote LeoQuote left a comment

Choose a reason for hiding this comment

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

我认为当前的实现还是有点混乱, 不需要把自动驳回和自动通过这两个逻辑混在一起.

自动驳回和自动通过这两个功能应该是相对独立的, 自动驳回优先. 所以你应该在最一开始的时候判断能否自动驳回, 这样就没有后来的自动通过的事情了.

@woshiyanghai
Copy link
Contributor

对,自动驳回并不是自动审核流程这两个是独立的。 所以在提交工单时,如果发现时自动驳回的单子,就直接设置为2,后续没有自动审核逻辑了。这样这个单子系统也能看到,不同级别有权限的也能看到,也又对应的日志。

@LeoQuote
Copy link
Collaborator

LeoQuote commented Jul 3, 2024

这一版还是和自动通过结合了, 在这一步之前再做一个处理, 如果 workflow status 是 autoreview_wrong ,那么就提前保存, return , 你看能不能解决你的问题.

# 自动通过的情况
if audit_setting.auto_pass:
self.audit.current_status = WorkflowStatus.PASSED
self.audit.save()
WorkflowLog.objects.create(
audit_id=self.audit.audit_id,
operation_type=WorkflowAction.SUBMIT,
operation_type_desc=WorkflowAction.SUBMIT.label,
operation_info="无需审批,系统直接审核通过",
operator=self.audit.create_user,
operator_display=self.audit.create_user_display,
)
return "无需审批, 直接审核通过"

@peixubin
Copy link
Contributor Author

peixubin commented Jul 3, 2024

这一版还是和自动通过结合了, 在这一步之前再做一个处理, 如果 workflow status 是 autoreview_wrong ,那么就提前保存, return , 你看能不能解决你的问题.

# 自动通过的情况
if audit_setting.auto_pass:
self.audit.current_status = WorkflowStatus.PASSED
self.audit.save()
WorkflowLog.objects.create(
audit_id=self.audit.audit_id,
operation_type=WorkflowAction.SUBMIT,
operation_type_desc=WorkflowAction.SUBMIT.label,
operation_info="无需审批,系统直接审核通过",
operator=self.audit.create_user,
operator_display=self.audit.create_user_display,
)
return "无需审批, 直接审核通过"

对于自动驳回和自动通过是否结合,我不能理解。驳回或通过本来就是审核的两个动作,在create_audit里面必定会存在驳回或通过两个场景,这有什么值得疑问的?
大部分代码是原来就有的,我还不想去大动。我只是增加了对工单状态的判断。
`
239 def generate_audit_setting(self) -> AuditSetting:
240 if self.is_auto_review():
241 if self.workflow_type in [WorkflowType.SQL_REVIEW, WorkflowType.QUERY]:
242 if self.workflow.status != "workflow_autoreviewwrong":
243 return AuditSetting(auto_pass=True)

`

@LeoQuote
Copy link
Collaborator

LeoQuote commented Jul 3, 2024

可能之前表达的不清晰, 我重复表达下我的建议:

  1. 是否自动驳回和是否自动通过是两个逻辑, 自动驳回优先, 先判断是否自动驳回, 再判断是否自动通过, 这样逻辑清晰, 容易理解, 不要混在一起.
  2. 驳回还是不驳回, 不适宜放在 generate_audit_settings 内, 就如这个函数名字描述的一样, 是生成工单对应的审批流, 是否自动通过, 审核节点是哪些, 等等. 驳回还是不驳回适宜放在 create_audit 内.

希望你能理解.

Comment on lines 303 to 306
if (
audit_setting.auto_pass
and self.workflow.status == "workflow_autoreviewwrong"
):
Copy link
Collaborator

Choose a reason for hiding this comment

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

无需判断是否 auto_pass, 逻辑更清晰

Suggested change
if (
audit_setting.auto_pass
and self.workflow.status == "workflow_autoreviewwrong"
):
if self.workflow.status == "workflow_autoreviewwrong":

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我的想法是手工确认的模式下,不执行自动驳回

Copy link
Collaborator

Choose a reason for hiding this comment

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

不行, 你的这个需求是 breaking change 了, 需要做系统配置控制行为

Copy link
Collaborator

Choose a reason for hiding this comment

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

如果你需要, 可以独立成一个函数, should_reject , 然后你定制开发时覆盖这个函数即可. 这样也可以控制审批流的行为.

参考:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

意思是对于错误工单,提交后可以修改?
这样当然是好的,但是这个状态怎么设置,没搞清楚

Copy link
Contributor Author

Choose a reason for hiding this comment

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

前面我也问了,这个“breaking change”是什么意思,没搞明白。
在自动审核模式下,存在错误的工单,不应该驳回吗? 还需要参数进行开关?

Copy link
Collaborator

Choose a reason for hiding this comment

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

breaking change 就是和之前版本不一致的行为,对于你的两个问题我就不重复回答了,请参照上方粗体部分的说明。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我觉得需要分析的是,是否存在其它场景,不符合我实现的逻辑。

Copy link
Collaborator

Choose a reason for hiding this comment

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

这里可能还是有一些矛盾在的哈,我觉得我观点都表达到位了。如果没有代码改变,新的观点或论据,我就不反复沟通了。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

目前的实现与原来的逻辑基本没有差别了,只是在判断是否自动通过时,增加了对存在审核错误的检查,其实和最早的实现类似。
另外增加了一个系统参数,是否要允许错误脚本提交(仅自动审核模式下),目前是在客户端脚本里进行判断。

@hhyo
Copy link
Owner

hhyo commented Aug 24, 2024

#2772 已处理

@hhyo hhyo closed this Aug 24, 2024
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.

4 participants