@@ -51,7 +51,7 @@ type AppListingRepository interface {
51
51
DeploymentDetailByArtifactId (ciArtifactId int , envId int ) (AppView.DeploymentDetailContainer , error )
52
52
FindAppCount (isProd bool ) (int , error )
53
53
FetchAppsByEnvironmentV2 (appListingFilter helper.AppListingFilter ) ([]* AppView.AppEnvironmentContainer , int , error )
54
- FetchAppsEnvContainers (envId , limit , offset int ) ([]* AppView.AppEnvironmentContainer , error )
54
+ FetchAppsEnvContainers (envId , limit , offset int , appIds [] int ) ([]* AppView.AppEnvironmentContainer , error )
55
55
FetchLastDeployedImage (appId , envId int ) (* LastDeployed , error )
56
56
}
57
57
@@ -137,25 +137,35 @@ func (impl *AppListingRepositoryImpl) FetchOverviewCiPipelines(jobId int) ([]*Ap
137
137
return jobContainers , nil
138
138
}
139
139
140
- func (impl * AppListingRepositoryImpl ) FetchAppsEnvContainers (envId , limit , offset int ) ([]* AppView.AppEnvironmentContainer , error ) {
140
+ func (impl * AppListingRepositoryImpl ) FetchAppsEnvContainers (envId int , limit , offset int , appIds [] int ) ([]* AppView.AppEnvironmentContainer , error ) {
141
141
query := ` SELECT a.id as app_id,a.app_name,aps.status as app_status, ld.last_deployed_time, p.id as pipeline_id
142
142
FROM app a
143
143
INNER JOIN pipeline p ON p.app_id = a.id and p.deleted = false and p.environment_id = ?
144
144
LEFT JOIN app_status aps ON aps.app_id = a.id and aps.env_id = ?
145
145
LEFT JOIN
146
146
(SELECT pco.pipeline_id,MAX(pco.created_on) as last_deployed_time from pipeline_config_override pco
147
147
GROUP BY pco.pipeline_id) ld ON ld.pipeline_id = p.id
148
- WHERE a.active = true
149
- ORDER BY a.app_name `
148
+ WHERE a.active = true`
149
+
150
150
queryParams := []interface {}{envId , envId }
151
+
152
+ // Add app IDs filter if provided
153
+ if len (appIds ) > 0 {
154
+ query += " AND a.id IN (?)"
155
+ queryParams = append (queryParams , pg .In (appIds ))
156
+ }
157
+
158
+ query += " ORDER BY a.app_name"
159
+
151
160
if limit > 0 {
152
- query += fmt . Sprintf ( " LIMIT ? " )
161
+ query += " LIMIT ?"
153
162
queryParams = append (queryParams , limit )
154
163
}
155
164
if offset > 0 {
156
- query += fmt . Sprintf ( " OFFSET ? " )
165
+ query += " OFFSET ?"
157
166
queryParams = append (queryParams , offset )
158
167
}
168
+
159
169
var envContainers []* AppView.AppEnvironmentContainer
160
170
_ , err := impl .dbConnection .Query (& envContainers , query , queryParams ... )
161
171
return envContainers , err
0 commit comments