@@ -19,7 +19,6 @@ package pipelineConfig
19
19
import (
20
20
"context"
21
21
"errors"
22
- "fmt"
23
22
apiBean "github.com/devtron-labs/devtron/api/bean"
24
23
"github.com/devtron-labs/devtron/internal/sql/repository"
25
24
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow"
@@ -29,7 +28,6 @@ import (
29
28
"github.com/go-pg/pg"
30
29
"go.opentelemetry.io/otel"
31
30
"go.uber.org/zap"
32
- "strings"
33
31
"time"
34
32
)
35
33
@@ -71,7 +69,7 @@ type CdWorkflowRepository interface {
71
69
IsLatestWf (pipelineId int , wfId int ) (bool , error )
72
70
FindLatestCdWorkflowByPipelineId (pipelineIds []int ) (* CdWorkflow , error )
73
71
FindLatestCdWorkflowByPipelineIdV2 (pipelineIds []int ) ([]* CdWorkflow , error )
74
- FetchAllCdStagesLatestEntity (pipelineWorkflowPairs map [ int ][]apiBean. WorkflowType ) ([]* CdWorkflowStatus , error )
72
+ FetchAllCdStagesLatestEntity (pipelineIds [] int ) ([]* CdWorkflowStatus , error )
75
73
FetchAllCdStagesLatestEntityStatus (wfrIds []int ) ([]* CdWorkflowRunner , error )
76
74
ExistsByStatus (status string ) (bool , error )
77
75
FetchEnvAllCdStagesLatestEntityStatus (wfrIds []int , envID int ) ([]* CdWorkflowRunner , error )
@@ -580,15 +578,15 @@ func (impl *CdWorkflowRepositoryImpl) IsLatestWf(pipelineId int, wfId int) (bool
580
578
return ! exists , err
581
579
}
582
580
583
- func (impl * CdWorkflowRepositoryImpl ) FetchAllCdStagesLatestEntity (pipelineWorkflowPairs map [ int ][]apiBean. WorkflowType ) ([]* CdWorkflowStatus , error ) {
581
+ func (impl * CdWorkflowRepositoryImpl ) FetchAllCdStagesLatestEntity (pipelineIds [] int ) ([]* CdWorkflowStatus , error ) {
584
582
var cdWorkflowStatus []* CdWorkflowStatus
585
- if len (pipelineWorkflowPairs ) == 0 {
583
+ if len (pipelineIds ) == 0 {
586
584
return cdWorkflowStatus , nil
587
585
}
588
586
query := "select p.ci_pipeline_id, wf.pipeline_id, wfr.workflow_type, max(wfr.id) as wfr_id from cd_workflow_runner wfr" +
589
587
" inner join cd_workflow wf on wf.id=wfr.cd_workflow_id" +
590
588
" inner join pipeline p on p.id = wf.pipeline_id" +
591
- " where ( wf.pipeline_id, wfr.workflow_type) in (" + buildPipelineTypeValuesList ( pipelineWorkflowPairs ) + ")" +
589
+ " where wf.pipeline_id in (" + sqlIntSeq ( pipelineIds ) + ")" +
592
590
" group by p.ci_pipeline_id, wf.pipeline_id, wfr.workflow_type order by wfr_id desc;"
593
591
_ , err := impl .dbConnection .Query (& cdWorkflowStatus , query )
594
592
if err != nil {
@@ -598,15 +596,6 @@ func (impl *CdWorkflowRepositoryImpl) FetchAllCdStagesLatestEntity(pipelineWorkf
598
596
return cdWorkflowStatus , nil
599
597
}
600
598
601
- func buildPipelineTypeValuesList (pairs map [int ][]apiBean.WorkflowType ) string {
602
- var values []string
603
- for pipelineId , workflowTypes := range pairs {
604
- for _ , workflowType := range workflowTypes {
605
- values = append (values , fmt .Sprintf ("(%d,'%s')" , pipelineId , workflowType ))
606
- }
607
- }
608
- return strings .Join (values , "," )
609
- }
610
599
func (impl * CdWorkflowRepositoryImpl ) FetchAllCdStagesLatestEntityStatus (wfrIds []int ) ([]* CdWorkflowRunner , error ) {
611
600
var wfrList []* CdWorkflowRunner
612
601
err := impl .dbConnection .Model (& wfrList ).
0 commit comments