Skip to content

Commit e1e3740

Browse files
committed
fix: add filter condition source and deleted_at is NULL for get last start/receive time
1 parent be13b8f commit e1e3740

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sqle/model/instance_audit_plan.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,16 @@ func (a *AuditPlanV2) GetBaseInfo() BaseAuditPlan {
172172
}
173173
}
174174

175-
func (s *Storage) GetLatestStartTimeAuditPlanSQLV2(sourceId uint) (string, error) {
175+
func (s *Storage) GetLatestStartTimeAuditPlanSQLV2(sourceId uint, typ string) (string, error) {
176176
info := struct {
177177
StartTime string `gorm:"column:max_start_time"`
178178
}{}
179179
err := s.db.Raw(`SELECT MAX(STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(info, '$.start_time_of_last_scraped_sql')), '%Y-%m-%dT%H:%i:%s.%f'))
180-
AS max_start_time FROM sql_manage_records WHERE source_id = ?`, sourceId).Scan(&info).Error
180+
AS max_start_time FROM sql_manage_records WHERE source_id = ? AND source = ? AND deleted_at is NULL`, sourceId, typ).Scan(&info).Error
181181
return info.StartTime, err
182182
}
183183

184-
func (s *Storage) GetLastReceiveTimeAuditPlanSQLV2(sourceId uint) (string, error) {
184+
func (s *Storage) GetLastReceiveTimeAuditPlanSQLV2(sourceId uint, typ string) (string, error) {
185185
var info = struct {
186186
LastReceivedTime string `gorm:"column:last_received_time"`
187187
}{}
@@ -191,9 +191,9 @@ func (s *Storage) GetLastReceiveTimeAuditPlanSQLV2(sourceId uint) (string, error
191191
JSON_UNQUOTE(JSON_EXTRACT(info, '$.last_receive_timestamp'))
192192
)
193193
AS last_received_time
194-
FROM sqle.sql_manage_records
195-
WHERE source_id = ?
196-
`, sourceId).Scan(&info).Error
194+
FROM sql_manage_records
195+
WHERE source_id = ? AND source = ? AND deleted_at is NULL
196+
`, sourceId, typ).Scan(&info).Error
197197
return info.LastReceivedTime, err
198198
}
199199

0 commit comments

Comments
 (0)