Skip to content

Commit 2824505

Browse files
committed
fix
1 parent 22ee1c9 commit 2824505

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

client/telemetry/telemetryQueries.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import (
66
)
77

88
func (impl *TelemetryEventClientImpl) getHelmAppCount() int {
9+
if impl.installedAppReadService == nil {
10+
impl.logger.Warnw("installedAppReadService not available for helm app count")
11+
return -1
12+
}
913
count, err := impl.installedAppReadService.GetActiveInstalledAppCount()
1014
if err != nil {
1115
impl.logger.Errorw("error getting helm app count", "err", err)
@@ -15,6 +19,10 @@ func (impl *TelemetryEventClientImpl) getHelmAppCount() int {
1519
}
1620

1721
func (impl *TelemetryEventClientImpl) getDevtronAppCount() int {
22+
if impl.appRepository == nil {
23+
impl.logger.Warnw("appRepository not available for devtron app count")
24+
return -1
25+
}
1826
devtronAppCount, err := impl.appRepository.FindDevtronAppCount()
1927
if err != nil {
2028
impl.logger.Errorw("error getting all apps for devtron app count", "err", err)
@@ -24,6 +32,10 @@ func (impl *TelemetryEventClientImpl) getDevtronAppCount() int {
2432
}
2533

2634
func (impl *TelemetryEventClientImpl) getJobCount() int {
35+
if impl.appRepository == nil {
36+
impl.logger.Warnw("appRepository not available for job count")
37+
return -1
38+
}
2739
jobCount, err := impl.appRepository.FindJobCount()
2840
if err != nil {
2941
impl.logger.Errorw("error getting all apps for job count", "err", err)
@@ -34,6 +46,11 @@ func (impl *TelemetryEventClientImpl) getJobCount() int {
3446
}
3547

3648
func (impl *TelemetryEventClientImpl) getUserCreatedPluginCount() int {
49+
if impl.pluginRepository == nil {
50+
impl.logger.Warnw("pluginRepository not available for user created plugin count")
51+
return -1
52+
}
53+
3754
// Get all user-created plugins (SHARED type)
3855
plugins, err := impl.pluginRepository.GetAllPluginMinDataByType(string(repository.PLUGIN_TYPE_SHARED))
3956
if err != nil {
@@ -45,6 +62,11 @@ func (impl *TelemetryEventClientImpl) getUserCreatedPluginCount() int {
4562
}
4663

4764
func (impl *TelemetryEventClientImpl) getPolicyCount() int {
65+
if impl.cvePolicyRepository == nil {
66+
impl.logger.Warnw("cvePolicyRepository not available for policy count")
67+
return -1
68+
}
69+
4870
// Get global policies
4971
globalPolicies, err := impl.cvePolicyRepository.GetGlobalPolicies()
5072
if err != nil {
@@ -79,6 +101,12 @@ func (impl *TelemetryEventClientImpl) getJobPipelineCount() int {
79101
}
80102

81103
func (impl *TelemetryEventClientImpl) getJobPipelineTriggeredLast24h() int {
104+
// Check if we have the required dependency
105+
if impl.ciWorkflowRepository == nil {
106+
impl.logger.Warnw("ciWorkflowRepository not available for job pipeline triggered count")
107+
return -1
108+
}
109+
82110
// Get build type and status data for the last 24 hours
83111
buildTypeStatusData := impl.ciWorkflowRepository.FindBuildTypeAndStatusDataOfLast1Day()
84112
if buildTypeStatusData == nil {
@@ -99,6 +127,12 @@ func (impl *TelemetryEventClientImpl) getJobPipelineTriggeredLast24h() int {
99127
}
100128

101129
func (impl *TelemetryEventClientImpl) getJobPipelineSucceededLast24h() int {
130+
// Check if we have the required dependency
131+
if impl.ciWorkflowRepository == nil {
132+
impl.logger.Warnw("ciWorkflowRepository not available for job pipeline succeeded count")
133+
return -1
134+
}
135+
102136
// Get build type and status data for the last 24 hours
103137
buildTypeStatusData := impl.ciWorkflowRepository.FindBuildTypeAndStatusDataOfLast1Day()
104138
if buildTypeStatusData == nil {

0 commit comments

Comments
 (0)