@@ -6,6 +6,10 @@ import (
6
6
)
7
7
8
8
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
+ }
9
13
count , err := impl .installedAppReadService .GetActiveInstalledAppCount ()
10
14
if err != nil {
11
15
impl .logger .Errorw ("error getting helm app count" , "err" , err )
@@ -15,6 +19,10 @@ func (impl *TelemetryEventClientImpl) getHelmAppCount() int {
15
19
}
16
20
17
21
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
+ }
18
26
devtronAppCount , err := impl .appRepository .FindDevtronAppCount ()
19
27
if err != nil {
20
28
impl .logger .Errorw ("error getting all apps for devtron app count" , "err" , err )
@@ -24,6 +32,10 @@ func (impl *TelemetryEventClientImpl) getDevtronAppCount() int {
24
32
}
25
33
26
34
func (impl * TelemetryEventClientImpl ) getJobCount () int {
35
+ if impl .appRepository == nil {
36
+ impl .logger .Warnw ("appRepository not available for job count" )
37
+ return - 1
38
+ }
27
39
jobCount , err := impl .appRepository .FindJobCount ()
28
40
if err != nil {
29
41
impl .logger .Errorw ("error getting all apps for job count" , "err" , err )
@@ -34,6 +46,11 @@ func (impl *TelemetryEventClientImpl) getJobCount() int {
34
46
}
35
47
36
48
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
+
37
54
// Get all user-created plugins (SHARED type)
38
55
plugins , err := impl .pluginRepository .GetAllPluginMinDataByType (string (repository .PLUGIN_TYPE_SHARED ))
39
56
if err != nil {
@@ -45,6 +62,11 @@ func (impl *TelemetryEventClientImpl) getUserCreatedPluginCount() int {
45
62
}
46
63
47
64
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
+
48
70
// Get global policies
49
71
globalPolicies , err := impl .cvePolicyRepository .GetGlobalPolicies ()
50
72
if err != nil {
@@ -79,6 +101,12 @@ func (impl *TelemetryEventClientImpl) getJobPipelineCount() int {
79
101
}
80
102
81
103
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
+
82
110
// Get build type and status data for the last 24 hours
83
111
buildTypeStatusData := impl .ciWorkflowRepository .FindBuildTypeAndStatusDataOfLast1Day ()
84
112
if buildTypeStatusData == nil {
@@ -99,6 +127,12 @@ func (impl *TelemetryEventClientImpl) getJobPipelineTriggeredLast24h() int {
99
127
}
100
128
101
129
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
+
102
136
// Get build type and status data for the last 24 hours
103
137
buildTypeStatusData := impl .ciWorkflowRepository .FindBuildTypeAndStatusDataOfLast1Day ()
104
138
if buildTypeStatusData == nil {
0 commit comments