-
Notifications
You must be signed in to change notification settings - Fork 2
record end_time in auto_rules_task_log #909
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import json | ||
| from datetime import date | ||
| from datetime import date, timedelta | ||
| from types import SimpleNamespace | ||
|
|
||
| from sqlalchemy import text | ||
|
|
@@ -154,8 +154,8 @@ def update_stats(self, db_session, auto_rule_result: AutomationResult): | |
| UPDATE dtable_automation_rules SET last_trigger_time=:trigger_time, is_valid=:is_valid, trigger_count=trigger_count+1 WHERE id=:rule_id; | ||
| ''' | ||
| insert_rule_log = ''' | ||
| INSERT INTO auto_rules_task_log (trigger_time, success, rule_id, run_condition, dtable_uuid, org_id, owner, warnings) VALUES | ||
| (:trigger_time, :success, :rule_id, :run_condition, :dtable_uuid, :org_id, :owner, :warnings) | ||
| INSERT INTO auto_rules_task_log (trigger_time, end_time, success, rule_id, run_condition, dtable_uuid, org_id, owner, warnings) VALUES | ||
| (:trigger_time, :end_time, :success, :rule_id, :run_condition, :dtable_uuid, :org_id, :owner, :warnings) | ||
| ''' | ||
| org_id = auto_rule_result.org_id | ||
| owner = auto_rule_result.owner | ||
|
|
@@ -179,6 +179,7 @@ def update_stats(self, db_session, auto_rule_result: AutomationResult): | |
| 'owner': auto_rule_result.owner, | ||
| 'trigger_time': auto_rule_result.trigger_time, | ||
| 'trigger_date': auto_rule_result.trigger_date, | ||
| 'end_time': auto_rule_result.trigger_time + timedelta(seconds=auto_rule_result.run_time), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Warning] 新增时间计算缺少回归覆盖 Why this matters: Suggested fix: 为 |
||
| 'is_valid': auto_rule_result.is_valid, | ||
| 'success': 1 if auto_rule_result.success else 0, | ||
| 'run_condition': auto_rule_result.run_condition, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Critical] 缺少数据库升级脚本
Why this matters:
现有 SeaTable 部署的
auto_rules_task_log尚无end_time列,而这里会在每次自动化完成时执行包含该列的 INSERT,导致 MySQL 报“Unknown column”,统计更新和日志写入都会回滚。配套 dtable-web PR 也没有更新初始建表 SQL,因此新安装同样不具备该列。Suggested fix: 在 dtable-web 的对应版本升级 SQL 中增加可重复执行的
ALTER TABLE auto_rules_task_log ADD COLUMN ... end_time DATETIME(6) NULL,并同步更新sql/mysql.sql的建表定义;部署 dtable-events 前必须先执行该迁移。