Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion api/restHandler/app/BuildPipelineRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,13 @@ func (handler PipelineConfigRestHandlerImpl) FetchMaterialInfo(w http.ResponseWr
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
envId, err := strconv.Atoi(vars["envId"])
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
handler.Logger.Infow("request payload, FetchMaterialInfo", "err", err, "ciArtifactId", ciArtifactId)
resp, err := handler.ciHandler.FetchMaterialInfoByArtifactId(ciArtifactId)
resp, err := handler.ciHandler.FetchMaterialInfoByArtifactId(ciArtifactId, envId)
if err != nil {
handler.Logger.Errorw("service err, FetchMaterialInfo", "err", err, "ciArtifactId", ciArtifactId)
if util.IsErrNoRows(err) {
Expand Down
2 changes: 1 addition & 1 deletion api/router/PipelineConfigRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (router PipelineConfigRouterImpl) initPipelineConfigRouter(configRouter *mu
configRouter.Path("/workflow/status/{appId}").HandlerFunc(router.restHandler.FetchAppWorkflowStatusForTriggerView).Methods("GET")
configRouter.Path("/workflow/status/{appId}/{version}").HandlerFunc(router.restHandler.FetchAppWorkflowStatusForTriggerView).Methods("GET")

configRouter.Path("/material-info/{appId}/{ciArtifactId}").HandlerFunc(router.restHandler.FetchMaterialInfo).Methods("GET")
configRouter.Path("/material-info/{envId}/{ciArtifactId}").HandlerFunc(router.restHandler.FetchMaterialInfo).Methods("GET")
configRouter.Path("/ci-pipeline/webhook-payload/{pipelineMaterialId}").HandlerFunc(router.webhookDataRestHandler.GetWebhookPayloadDataForPipelineMaterialId).Methods("GET")
configRouter.Path("/ci-pipeline/webhook-payload/{pipelineMaterialId}/{parsedDataId}").HandlerFunc(router.webhookDataRestHandler.GetWebhookPayloadFilterDataForPipelineMaterialId).Methods("GET")
configRouter.Path("/ci-pipeline/{appId}/{pipelineId}").HandlerFunc(router.restHandler.GetCIPipelineById).Methods("GET")
Expand Down
8 changes: 4 additions & 4 deletions internal/sql/repository/AppListingRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type AppListingRepository interface {

FetchOtherEnvironment(appId int) ([]*bean.Environment, error)
FetchMinDetailOtherEnvironment(appId int) ([]*bean.Environment, error)
DeploymentDetailByArtifactId(ciArtifactId int) (bean.DeploymentDetailContainer, error)
DeploymentDetailByArtifactId(ciArtifactId int, envId int) (bean.DeploymentDetailContainer, error)
FindAppCount(isProd bool) (int, error)
FetchAppsByEnvironmentV2(appListingFilter helper.AppListingFilter) ([]*bean.AppEnvironmentContainer, int, error)
FetchOverviewAppsByEnvironment(envId, limit, offset int) ([]*bean.AppEnvironmentContainer, error)
Expand Down Expand Up @@ -661,19 +661,19 @@ func (impl AppListingRepositoryImpl) FetchMinDetailOtherEnvironment(appId int) (
return otherEnvironments, nil
}

func (impl AppListingRepositoryImpl) DeploymentDetailByArtifactId(ciArtifactId int) (bean.DeploymentDetailContainer, error) {
func (impl AppListingRepositoryImpl) DeploymentDetailByArtifactId(ciArtifactId int, envId int) (bean.DeploymentDetailContainer, error) {
impl.Logger.Debug("reached at AppListingRepository:")
var deploymentDetail bean.DeploymentDetailContainer
query := "SELECT env.id AS environment_id, env.environment_name, env.default, pco.created_on as last_deployed_time, a.app_name" +
" FROM pipeline_config_override pco" +
" INNER JOIN pipeline p on p.id = pco.pipeline_id" +
" INNER JOIN environment env ON env.id=p.environment_id" +
" INNER JOIN app a on a.id = p.app_id" +
" WHERE pco.ci_artifact_id = ? and p.deleted=false AND env.active = TRUE" +
" WHERE pco.ci_artifact_id = ? and p.deleted=false AND env.active = TRUE AND env.id = ?" +
" ORDER BY pco.pipeline_release_counter desc LIMIT 1;"
impl.Logger.Debugw("last success full deployed artifact query:", query)

_, err := impl.dbConnection.Query(&deploymentDetail, query, ciArtifactId)
_, err := impl.dbConnection.Query(&deploymentDetail, query, ciArtifactId, envId)
if err != nil {
impl.Logger.Errorw("Exception caught:", err)
return deploymentDetail, err
Expand Down
6 changes: 3 additions & 3 deletions pkg/pipeline/CiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type CiHandler interface {
FetchCiStatusForTriggerView(appId int) ([]*pipelineConfig.CiWorkflowStatus, error)
FetchCiStatusForTriggerViewV1(appId int) ([]*pipelineConfig.CiWorkflowStatus, error)
RefreshMaterialByCiPipelineMaterialId(gitMaterialId int) (refreshRes *gitSensor.RefreshGitMaterialResponse, err error)
FetchMaterialInfoByArtifactId(ciArtifactId int) (*GitTriggerInfoResponse, error)
FetchMaterialInfoByArtifactId(ciArtifactId int, envId int) (*GitTriggerInfoResponse, error)
WriteToCreateTestSuites(pipelineId int, buildId int, triggeredBy int)
UpdateCiWorkflowStatusFailure(timeoutForFailureCiBuild int) error
FetchCiStatusForTriggerViewForEnvironment(request appGroup2.AppGroupingRequest) ([]*pipelineConfig.CiWorkflowStatus, error)
Expand Down Expand Up @@ -1174,7 +1174,7 @@ func (impl *CiHandlerImpl) FetchCiStatusForTriggerView(appId int) ([]*pipelineCo
return ciWorkflowStatuses, nil
}

func (impl *CiHandlerImpl) FetchMaterialInfoByArtifactId(ciArtifactId int) (*GitTriggerInfoResponse, error) {
func (impl *CiHandlerImpl) FetchMaterialInfoByArtifactId(ciArtifactId int, envId int) (*GitTriggerInfoResponse, error) {

ciArtifact, err := impl.ciArtifactRepository.Get(ciArtifactId)
if err != nil {
Expand All @@ -1194,7 +1194,7 @@ func (impl *CiHandlerImpl) FetchMaterialInfoByArtifactId(ciArtifactId int) (*Git
return &GitTriggerInfoResponse{}, err
}

deployDetail, err := impl.appListingRepository.DeploymentDetailByArtifactId(ciArtifactId)
deployDetail, err := impl.appListingRepository.DeploymentDetailByArtifactId(ciArtifactId, envId)
if err != nil {
impl.Logger.Errorw("err", "err", err)
return &GitTriggerInfoResponse{}, err
Expand Down