Skip to content

Commit

Permalink
Fix errors in dora plugin (#7858) (#7859)
Browse files Browse the repository at this point in the history
* fix(dora): add more log in task ConnectIncidentToDeployment

* fix(dora): add select clause in tasks

* fix(dora): add more log

* fix(dora): fix count errors

* fix(dora): fix count errors

* fix(dora): fix wrong subtasks orders

Co-authored-by: Lynwee <1507509064@qq.com>
  • Loading branch information
github-actions[bot] and d4x1 authored Aug 7, 2024
1 parent bb1f54f commit f711103
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/plugins/dora/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ func (p Dora) SubTaskMetas() []plugin.SubTaskMeta {
tasks.EnrichPrevSuccessDeploymentCommitMeta,
tasks.EnrichTaskEnvMeta,
tasks.CalculateChangeLeadTimeMeta,
tasks.ConnectIncidentToDeploymentMeta,
tasks.IssuesToIncidentsMeta,
tasks.ConnectIncidentToDeploymentMeta,
}
}

Expand Down
21 changes: 12 additions & 9 deletions backend/plugins/dora/tasks/incident_deploy_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,21 @@ func ConnectIncidentToDeployment(taskCtx plugin.SubTaskContext) errors.Error {
logger.Info("delete previous project_incident_deployment_relationships")
// select all issues belongs to the board
clauses := []dal.Clause{
dal.Select(`i.*`),
dal.From(`incidents i`),
dal.Join(`left join project_mapping pm on pm.row_id = i.scope_id and pm.table = i.table`),
dal.Where("pm.project_name = ?", data.Options.ProjectName),
}

count, err := db.Count(clauses...)
if err != nil {
logger.Error(err, "count incidents")
} else {
logger.Info("incident count is %d", count)
}
//count, err := db.Count(
// dal.From(`incidents i`),
// dal.Join(`left join project_mapping pm on pm.row_id = i.scope_id and pm.table = i.table`),
// dal.Where("pm.project_name = ?", data.Options.ProjectName),
//)
//if err != nil {
// logger.Error(err, "count incidents")
//} else {
// logger.Info("incident count is %d", count)
//}

cursor, err := db.Cursor(clauses...)
if err != nil {
Expand All @@ -95,7 +98,7 @@ func ConnectIncidentToDeployment(taskCtx plugin.SubTaskContext) errors.Error {
},
ProjectName: data.Options.ProjectName,
}
logger.Info("get incident: %+v", incident.Id)
logger.Debug("get incident: %+v", incident.Id)
cicdDeploymentCommit := &devops.CicdDeploymentCommit{}
cicdDeploymentCommitClauses := []dal.Clause{
dal.Select("cicd_deployment_commits.cicd_deployment_id as id, cicd_deployment_commits.finished_date as finished_date"),
Expand Down Expand Up @@ -128,7 +131,7 @@ func ConnectIncidentToDeployment(taskCtx plugin.SubTaskContext) errors.Error {
projectIssueMetric.DeploymentId = scdc.Id
return []interface{}{projectIssueMetric}, nil
}
logger.Info("scdc.id is empty, incident will be ignored: %+v", incident.Id)
logger.Debug("scdc.id is empty, incident will be ignored: %+v", incident.Id)
return nil, nil
},
})
Expand Down

0 comments on commit f711103

Please sign in to comment.