Skip to content

Commit

Permalink
modify: modify handlerSQLAudit and modify UpdateManagerSQLBySqlId params
Browse files Browse the repository at this point in the history
  • Loading branch information
iwanghc committed Sep 6, 2024
1 parent 168776f commit c0e5d8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sqle/model/instance_audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,9 @@ func (s *Storage) UpdateManagerSQLStatus(txDB *gorm.DB, sql *SQLManageRecord) er
return txDB.Exec(query, sql.SQLID).Error
}

func (s *Storage) UpdateManagerSQLBySqlId(sql *SQLManageRecord) error {
err := s.db.Model(&SQLManageRecord{}).Where("sql_id = ?", sql.SQLID).
Updates(map[string]interface{}{"audit_level": sql.AuditLevel, "audit_results": sql.AuditResults, "priority": sql.Priority}).Error
func (s *Storage) UpdateManagerSQLBySqlId(sqlManageMap map[string]interface{}, sqlId string) error {
err := s.db.Model(&SQLManageRecord{}).Where("sql_id = ?", sqlId).
Updates(sqlManageMap).Error
if err != nil {
return err
}
Expand Down
10 changes: 7 additions & 3 deletions sqle/server/auditplan/job_task_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ func (j *AuditPlanHandlerJob) HandlerSQL(entry *logrus.Entry) {
return
}

go handlerSQLAudit(sqlList, entry)
go handlerSQLAudit(entry, sqlList)

}

// todo: 错误处理
func handlerSQLAudit(sqlList []*model.SQLManageRecord, entry *logrus.Entry) {
func handlerSQLAudit(entry *logrus.Entry, sqlList []*model.SQLManageRecord) {
s := model.GetStorage()
sqlList, err := BatchAuditSQLs(sqlList, true)
if err != nil {
Expand All @@ -111,7 +111,11 @@ func handlerSQLAudit(sqlList []*model.SQLManageRecord, entry *logrus.Entry) {
entry.Warnf("set sql priority sql failed, error: %v", err)
}
for _, sql := range sqlList {
err = s.UpdateManagerSQLBySqlId(sql)
manageSqlParam := make(map[string]interface{}, 3)
manageSqlParam["audit_level"] = sql.AuditLevel
manageSqlParam["audit_results"] = sql.AuditResults
manageSqlParam["priority"] = sql.Priority
err = s.UpdateManagerSQLBySqlId(manageSqlParam, sql.SQLID)
if err != nil {
entry.Warnf("update manager sql failed, error: %v", err)
continue
Expand Down

0 comments on commit c0e5d8f

Please sign in to comment.