@@ -18,12 +18,13 @@ limitations under the License.
1818package tasks
1919
2020import (
21+ "reflect"
22+
2123 "github.com/apache/incubator-devlake/core/dal"
2224 "github.com/apache/incubator-devlake/core/errors"
2325 "github.com/apache/incubator-devlake/core/models/domainlayer/code"
2426 "github.com/apache/incubator-devlake/core/plugin"
2527 "github.com/apache/incubator-devlake/plugins/refdiff/utils"
26- "reflect"
2728)
2829
2930func CommitDiffConvertor (pipelineCommitShaList []string , existFinishedCommitDiff []code.FinishedCommitsDiff ) (commitPairs []code.CommitsDiff , finishedCommitDiffs []code.FinishedCommitsDiff ) {
@@ -53,8 +54,8 @@ func CalculateProjectDeploymentCommitsDiff(taskCtx plugin.SubTaskContext) errors
5354
5455 cursorScope , err := db .Cursor (
5556 dal .Select ("row_id" ),
56- dal .From ("project_mapping" ),
57- dal .Where ("project_name = ?" , projectName ),
57+ dal .From ("project_mapping pm " ),
58+ dal .Where ("pm. project_name = ? and pm.table = ? " , projectName , "cicd_scopes" ),
5859 )
5960 if err != nil {
6061 return err
@@ -83,7 +84,7 @@ func CalculateProjectDeploymentCommitsDiff(taskCtx plugin.SubTaskContext) errors
8384 dal .From ("cicd_tasks ct" ),
8485 dal .Join ("left join cicd_pipelines cp on cp.id = ct.pipeline_id" ),
8586 dal .Join ("left join cicd_pipeline_commits cpc on cpc.pipeline_id = cp.id" ),
86- dal .Where ("ct.type = ? and commit_sha != ? and repo_id=? " , "DEPLOYMENT" , "" , scopeId ),
87+ dal .Where ("ct.environment = ? and ct. type = ? and ct.result = ? and commit_sha != ? and repo_id=? " , "PRODUCTION" , " DEPLOYMENT" , "SUCCESS " , "" , scopeId ),
8788 dal .Orderby ("ct.started_date" ),
8889 )
8990 if err != nil {
0 commit comments