Skip to content

Commit

Permalink
Merge pull request #2823 from actiontech/fix_audit_plan_detail_error
Browse files Browse the repository at this point in the history
fix: add audit status for sqls, fix unmarshal error
  • Loading branch information
winfredLIN authored Dec 16, 2024
2 parents f9f1c23 + a18db8b commit f0bcb90
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
9 changes: 7 additions & 2 deletions sqle/model/instance_audit_plan_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ type InstanceAuditPlanSQLListDetail struct {
Schema string `json:"schema_name"`
Info JSON `json:"info"`
AuditResult AuditResults `json:"audit_results"`
AuditStatus string `json:"audit_status"`
Priority sql.NullString `json:"priority"`
}

const AuditResultName = "audit_results"
const (
AuditResultName = "audit_results"
AuditStatus = "audit_status"
)

var AuditResultDesc = locale.ApAuditResult

Expand Down Expand Up @@ -170,7 +174,8 @@ audit_plan_sqls.sql_fingerprint,
audit_plan_sqls.sql_text,
audit_plan_sqls.schema_name,
audit_plan_sqls.info,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited',audit_plan_sqls.audit_results) AS audit_results,
audit_plan_sqls.audit_results,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited','') AS audit_status,
audit_plan_sqls.priority
{{- template "body" . -}}
Expand Down
18 changes: 12 additions & 6 deletions sqle/model/instance_audit_plan_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ audit_plan_sqls.sql_fingerprint,
audit_plan_sqls.sql_text,
audit_plan_sqls.schema_name,
audit_plan_sqls.info,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited',audit_plan_sqls.audit_results) AS audit_results,
audit_plan_sqls.audit_results,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited','') AS audit_status,
audit_plan_sqls.priority
FROM sql_manage_records AS audit_plan_sqls
Expand All @@ -59,7 +60,8 @@ audit_plan_sqls.sql_fingerprint,
audit_plan_sqls.sql_text,
audit_plan_sqls.schema_name,
audit_plan_sqls.info,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited',audit_plan_sqls.audit_results) AS audit_results,
audit_plan_sqls.audit_results,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited','') AS audit_status,
audit_plan_sqls.priority
FROM sql_manage_records AS audit_plan_sqls
Expand Down Expand Up @@ -87,7 +89,8 @@ audit_plan_sqls.sql_fingerprint,
audit_plan_sqls.sql_text,
audit_plan_sqls.schema_name,
audit_plan_sqls.info,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited',audit_plan_sqls.audit_results) AS audit_results,
audit_plan_sqls.audit_results,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited','') AS audit_status,
audit_plan_sqls.priority
FROM sql_manage_records AS audit_plan_sqls
Expand Down Expand Up @@ -115,7 +118,8 @@ audit_plan_sqls.sql_fingerprint,
audit_plan_sqls.sql_text,
audit_plan_sqls.schema_name,
audit_plan_sqls.info,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited',audit_plan_sqls.audit_results) AS audit_results,
audit_plan_sqls.audit_results,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited','') AS audit_status,
audit_plan_sqls.priority
FROM sql_manage_records AS audit_plan_sqls
Expand Down Expand Up @@ -144,7 +148,8 @@ audit_plan_sqls.sql_fingerprint,
audit_plan_sqls.sql_text,
audit_plan_sqls.schema_name,
audit_plan_sqls.info,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited',audit_plan_sqls.audit_results) AS audit_results,
audit_plan_sqls.audit_results,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited','') AS audit_status,
audit_plan_sqls.priority
FROM sql_manage_records AS audit_plan_sqls
Expand Down Expand Up @@ -172,7 +177,8 @@ audit_plan_sqls.sql_fingerprint,
audit_plan_sqls.sql_text,
audit_plan_sqls.schema_name,
audit_plan_sqls.info,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited',audit_plan_sqls.audit_results) AS audit_results,
audit_plan_sqls.audit_results,
IF(audit_plan_sqls.audit_results IS NULL,'being_audited','') AS audit_status,
audit_plan_sqls.priority
FROM sql_manage_records AS audit_plan_sqls
Expand Down
1 change: 1 addition & 0 deletions sqle/server/auditplan/task_type_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func (at *DefaultTaskV2) GetSQLData(ctx context.Context, ap *AuditPlan, persist
MetricNameCounter: strconv.Itoa(int(info.Get(MetricNameCounter).Int())),
MetricNameLastReceiveTimestamp: info.Get(MetricNameLastReceiveTimestamp).String(),
model.AuditResultName: sql.AuditResult.GetAuditJsonStrByLangTag(locale.Bundle.GetLangTagFromCtx(ctx)),
model.AuditStatus: sql.AuditStatus,
})
}
return rows, count, nil
Expand Down
1 change: 1 addition & 0 deletions sqle/server/auditplan/task_type_mysql_schema_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ func (at *BaseSchemaMetaTaskV2) GetSQLData(ctx context.Context, ap *AuditPlan, p
MetricNameMetaName: info.Get(MetricNameMetaName).String(),
MetricNameMetaType: info.Get(MetricNameMetaType).String(),
model.AuditResultName: sql.AuditResult.GetAuditJsonStrByLangTag(locale.Bundle.GetLangTagFromCtx(ctx)),
model.AuditStatus: sql.AuditStatus,
})
}
return rows, count, nil
Expand Down
1 change: 1 addition & 0 deletions sqle/server/auditplan/task_type_oracle_topsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ func (at *OracleTopSQLTaskV2) GetSQLData(ctx context.Context, ap *AuditPlan, per
MetricNameBufferGetCounter: strconv.Itoa(int(info.Get(MetricNameBufferGetCounter).Int())),
MetricNameUserIOWaitTimeTotal: fmt.Sprintf("%v", utils.Round(info.Get(MetricNameUserIOWaitTimeTotal).Float()/1000, 3)),
model.AuditResultName: sql.AuditResult.GetAuditJsonStrByLangTag(locale.Bundle.GetLangTagFromCtx(ctx)),
model.AuditStatus: sql.AuditStatus,
})
}
return rows, count, nil
Expand Down

0 comments on commit f0bcb90

Please sign in to comment.