@@ -41,7 +41,6 @@ import (
4141 "github.com/devtron-labs/common-lib/utils/k8s"
4242 "github.com/devtron-labs/devtron/internal/sql/repository"
4343 appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app"
44- "github.com/devtron-labs/devtron/internal/sql/repository/helper"
4544 "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
4645 "github.com/devtron-labs/devtron/pkg/auth/sso"
4746 user2 "github.com/devtron-labs/devtron/pkg/auth/user"
@@ -275,7 +274,7 @@ func (impl *TelemetryEventClientImpl) SummaryDetailsForTelemetry() (cluster []be
275274// New methods for collecting additional telemetry metrics
276275
277276func (impl * TelemetryEventClientImpl ) getHelmAppCount () int {
278- count , err := impl .installedAppReadService .GetDeploymentSuccessfulStatusCountForTelemetry ()
277+ count , err := impl .installedAppReadService .GetActiveInstalledAppCount ()
279278 if err != nil {
280279 impl .logger .Errorw ("error getting helm app count" , "err" , err )
281280 return - 1
@@ -284,49 +283,21 @@ func (impl *TelemetryEventClientImpl) getHelmAppCount() int {
284283}
285284
286285func (impl * TelemetryEventClientImpl ) getDevtronAppCount () int {
287- // Use a simple approach - count all active apps that are not jobs
288- if impl .appRepository == nil {
289- impl .logger .Warnw ("appRepository not available for devtron app count" )
290- return - 1
291- }
292-
293- // Get all active apps and filter out jobs
294- apps , err := impl .appRepository .FindAll ()
286+ devtronAppCount , err := impl .appRepository .FindDevtronAppCount ()
295287 if err != nil {
296288 impl .logger .Errorw ("error getting all apps for devtron app count" , "err" , err )
297289 return - 1
298290 }
299-
300- devtronAppCount := 0
301- for _ , app := range apps {
302- if app .AppType != helper .Job && app .Active {
303- devtronAppCount ++
304- }
305- }
306-
307291 return devtronAppCount
308292}
309293
310294func (impl * TelemetryEventClientImpl ) getJobCount () int {
311- // Use a simple approach - count all active apps that are jobs
312- if impl .appRepository == nil {
313- impl .logger .Warnw ("appRepository not available for job count" )
314- return - 1
315- }
316-
317- apps , err := impl .appRepository .FindAll ()
295+ jobCount , err := impl .appRepository .FindJobCount ()
318296 if err != nil {
319297 impl .logger .Errorw ("error getting all apps for job count" , "err" , err )
320298 return - 1
321299 }
322300
323- jobCount := 0
324- for _ , app := range apps {
325- if app .AppType == helper .Job && app .Active {
326- jobCount ++
327- }
328- }
329-
330301 return jobCount
331302}
332303
0 commit comments