Skip to content

Commit

Permalink
black 代码
Browse files Browse the repository at this point in the history
  • Loading branch information
woshiyanghai committed Jul 18, 2024
1 parent c78bf80 commit 7c76ac5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion sql/sql_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ def execute(request):
}
return render(request, "error.html", context)
sys_config = SysConfig()
if not request.user.is_superuser and on_query_low_peak_time_ddl(workflow_id) is False:
if (
not request.user.is_superuser
and on_query_low_peak_time_ddl(workflow_id) is False
):
start = sys_config.get("query_low_peak_start", 0)
end = sys_config.get("query_low_peak_end", 24)
context = {
Expand Down
5 changes: 3 additions & 2 deletions sql/utils/sql_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def can_execute(user, workflow_id):
result = True
return result


def on_query_low_peak_time_ddl(workflow_id, run_date=None):
"""
判断是否是ddl,ddl必须在业务低峰期执行,包括人工执行和定时执行
Expand All @@ -49,8 +50,8 @@ def on_query_low_peak_time_ddl(workflow_id, run_date=None):
"""
config = SysConfig()
workflow_detail = SqlWorkflow.objects.get(id=workflow_id)
start = int(config.get("query_low_peak_start", ""))
end = int(config.get("query_low_peak_end", ""))
start = int(config.get("query_low_peak_start", 0))
end = int(config.get("query_low_peak_end", 0))
result = True
ctime = run_date or datetime.datetime.now()
hour = ctime.hour
Expand Down
10 changes: 8 additions & 2 deletions sql_api/api_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,17 @@ def post(self, request):
}
)
sys_config = SysConfig()
if not request.user.is_superuser and on_query_low_peak_time_ddl(workflow_id) is False:
if (
not request.user.is_superuser
and on_query_low_peak_time_ddl(workflow_id) is False
):
start = sys_config.get("query_low_peak_start", 0)
end = sys_config.get("query_low_peak_end", 24)
raise serializers.ValidationError(
{"errMsg": "管理员设置了业务低峰期时间范围:每天%s:00至%s,你只能在业务低峰时间范围执行DDL工单操作!" % (start, end)}
{
"errMsg": "管理员设置了业务低峰期时间范围:每天%s:00至%s,你只能在业务低峰时间范围执行DDL工单操作!"
% (start, end)
}
)

# 获取审核信息
Expand Down

0 comments on commit 7c76ac5

Please sign in to comment.