Skip to content

Commit 4385c37

Browse files
authored
Merge pull request #2121 from digma-ai/feature/statistics
Feature/statistics
2 parents 910ce2e + 2d41dd6 commit 4385c37

File tree

12 files changed

+362
-223
lines changed

12 files changed

+362
-223
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/analytics/AnalyticsService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ public InsightsStatsResult getInsightsStats(String spanCodeObjectId) throws Anal
507507
} catch (Exception e) {
508508
Log.debugWithException(LOGGER, project, e, "error calling insights stats", e.getMessage());
509509
}
510-
return new InsightsStatsResult(0, 0, 0, 0);
510+
return new InsightsStatsResult(0, 0, 0, 0, 0, 0);
511511
}
512512

513513
public HttpResponse lowLevelCall(HttpRequest request) throws AnalyticsServiceException {

ide-common/src/main/kotlin/org/digma/intellij/plugin/analytics/InsightStatsChangedEvent.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,12 @@ interface InsightStatsChangedEvent {
1313
)
1414
}
1515

16-
fun insightStatsChanged(scope: JsonNode?, analyticsInsightsCount: Int, issuesInsightsCount: Int, unreadInsightsCount: Int)
16+
fun insightStatsChanged(
17+
scope: JsonNode?,
18+
analyticsInsightsCount: Int,
19+
totalQueryResultCount: Int,
20+
unreadInsightsCount: Int,
21+
criticalInsightsCount: Int,
22+
allIssuesCount: Int
23+
)
1724
}

ide-common/src/main/kotlin/org/digma/intellij/plugin/scope/ScopeManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ScopeManager(private val project: Project) {
125125
private fun showHomeView(scope: SpanScope, insightsStats: InsightsStatsResult?) {
126126
val contentViewSwitcher = MainContentViewSwitcher.getInstance(project)
127127
if (insightsStats != null) {
128-
if (insightsStats.analyticsInsightsCount > 0 && insightsStats.issuesInsightsCount == 0) {
128+
if (insightsStats.analyticsInsightsCount > 0 && insightsStats.totalQueryResultCount == 0) {
129129
contentViewSwitcher.showAnalytics()
130130
return
131131
}

model/src/main/kotlin/org/digma/intellij/plugin/model/rest/insights/InsightsStatsResult.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,19 @@ import java.beans.ConstructorProperties
77
@JsonIgnoreProperties(ignoreUnknown = true)
88
data class InsightsStatsResult
99
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
10-
@ConstructorProperties("dismissedCount", "issuesInsightsCount", "analyticsInsightsCount", "unreadInsightsCount")
11-
constructor(val dismissedCount: Number, val issuesInsightsCount: Int, val analyticsInsightsCount: Int, val unreadInsightsCount: Int)
10+
@ConstructorProperties(
11+
"dismissedCount",
12+
"totalQueryResultCount",
13+
"analyticsInsightsCount",
14+
"unreadInsightsCount",
15+
"criticalInsightsCount",
16+
"allIssuesCount"
17+
)
18+
constructor(
19+
val dismissedCount: Number,
20+
val totalQueryResultCount: Int,
21+
val analyticsInsightsCount: Int,
22+
val unreadInsightsCount: Int,
23+
val criticalInsightsCount: Int,
24+
val allIssuesCount: Int
25+
)

src/main/kotlin/org/digma/intellij/plugin/ui/jcef/BaseMessageRouterHandler.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,20 +251,27 @@ abstract class BaseMessageRouterHandler(protected val project: Project) : Common
251251
if (scopeNode is NullNode) {
252252
val stats = AnalyticsService.getInstance(project).getInsightsStats(null)
253253
project.messageBus.syncPublisher(InsightStatsChangedEvent.INSIGHT_STATS_CHANGED_TOPIC)
254-
.insightStatsChanged(null, stats.analyticsInsightsCount, stats.issuesInsightsCount, stats.unreadInsightsCount)
254+
.insightStatsChanged(
255+
null,
256+
stats.analyticsInsightsCount,
257+
stats.totalQueryResultCount,
258+
stats.unreadInsightsCount,
259+
stats.criticalInsightsCount,
260+
stats.allIssuesCount
261+
)
255262
} else {
256263
val spanCodeObjectId = scopeNode.get("span").get("spanCodeObjectId").asText()
257264
val stats = AnalyticsService.getInstance(project).getInsightsStats(spanCodeObjectId)
258265
project.messageBus.syncPublisher(InsightStatsChangedEvent.INSIGHT_STATS_CHANGED_TOPIC)
259266
.insightStatsChanged(
260267
scopeNode,
261268
stats.analyticsInsightsCount,
262-
stats.issuesInsightsCount,
263-
stats.unreadInsightsCount
269+
stats.totalQueryResultCount,
270+
stats.unreadInsightsCount,
271+
stats.criticalInsightsCount,
272+
stats.allIssuesCount
264273
)
265274
}
266-
267-
268275
}
269276
}
270277

@@ -356,7 +363,7 @@ abstract class BaseMessageRouterHandler(protected val project: Project) : Common
356363
CodeLocation(listOf(), listOf()),
357364
false,
358365
insightsStats?.analyticsInsightsCount ?: 0,
359-
insightsStats?.issuesInsightsCount ?: 0,
366+
insightsStats?.totalQueryResultCount ?: 0,
360367
insightsStats?.unreadInsightsCount ?: 0
361368
)
362369
}

src/main/kotlin/org/digma/intellij/plugin/ui/jcef/JCefComponent.kt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private constructor(
232232
codeLocation,
233233
hasErrors,
234234
insightsStats?.analyticsInsightsCount ?: 0,
235-
insightsStats?.issuesInsightsCount ?: 0,
235+
insightsStats?.totalQueryResultCount ?: 0,
236236
insightsStats?.unreadInsightsCount ?: 0
237237
)
238238
} catch (e: Throwable) {
@@ -256,9 +256,24 @@ private constructor(
256256

257257
project.messageBus.connect(insightStatsChangeParentDisposable).subscribe(
258258
InsightStatsChangedEvent.INSIGHT_STATS_CHANGED_TOPIC, object : InsightStatsChangedEvent {
259-
override fun insightStatsChanged(scope: JsonNode?, analyticsInsightsCount: Int, issuesInsightsCount: Int, unreadInsightsCount: Int) {
259+
override fun insightStatsChanged(
260+
scope: JsonNode?,
261+
analyticsInsightsCount: Int,
262+
totalQueryResultCount: Int,
263+
unreadInsightsCount: Int,
264+
criticalInsightsCount: Int,
265+
allIssuesCount: Int
266+
) {
260267
try {
261-
sendSetInsightStatsMessage(jbCefBrowser.cefBrowser, scope, analyticsInsightsCount, issuesInsightsCount, unreadInsightsCount)
268+
sendSetInsightStatsMessage(
269+
jbCefBrowser.cefBrowser,
270+
scope,
271+
analyticsInsightsCount,
272+
totalQueryResultCount,
273+
unreadInsightsCount,
274+
criticalInsightsCount,
275+
allIssuesCount
276+
)
262277
} catch (e: Throwable) {
263278
ErrorReporter.getInstance().reportError("JCefComponent.insightStatsChanged", e)
264279
}

src/main/kotlin/org/digma/intellij/plugin/ui/jcef/JCefMessagesUtils.kt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,12 @@ fun sendScopeChangedMessage(
198198
codeLocation: CodeLocation,
199199
hasErrors: Boolean,
200200
analyticsInsightsCount: Number,
201-
issuesInsightsCount: Number,
201+
totalQueryResultCount: Number,
202202
unreadInsightsCount: Number
203203
) {
204204
serializeAndExecuteWindowPostMessageJavaScript(
205-
cefBrowser, SetScopeMessage(SetScopeMessagePayload(scope, codeLocation, hasErrors, analyticsInsightsCount, issuesInsightsCount, unreadInsightsCount))
205+
cefBrowser,
206+
SetScopeMessage(SetScopeMessagePayload(scope, codeLocation, hasErrors, analyticsInsightsCount, totalQueryResultCount, unreadInsightsCount))
206207
)
207208
}
208209

@@ -230,10 +231,22 @@ fun sendSetInsightStatsMessage(
230231
cefBrowser: CefBrowser,
231232
scope: JsonNode?,
232233
analyticsInsightsCount: Number,
233-
issuesInsightsCount: Number,
234-
unreadInsightsCount: Number
234+
totalQueryResultCount: Number,
235+
unreadInsightsCount: Number,
236+
criticalInsightsCount: Number,
237+
allIssuesCount: Number
235238
) {
236239
serializeAndExecuteWindowPostMessageJavaScript(
237-
cefBrowser, SetInsightStatsMessage(SetInsightStatsMessagePayload(scope, analyticsInsightsCount, issuesInsightsCount, unreadInsightsCount))
240+
cefBrowser,
241+
SetInsightStatsMessage(
242+
SetInsightStatsMessagePayload(
243+
scope,
244+
analyticsInsightsCount,
245+
totalQueryResultCount,
246+
unreadInsightsCount,
247+
criticalInsightsCount,
248+
allIssuesCount
249+
)
250+
)
238251
)
239252
}

src/main/kotlin/org/digma/intellij/plugin/ui/jcef/model/ScopeMessages.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ data class SetScopeMessagePayload(
1515
val code: CodeLocation,
1616
val hasErrors: Boolean,
1717
val analyticsInsightsCount: Number,
18-
val issuesInsightsCount: Number,
18+
val totalQueryResultCount: Number,
1919
val unreadInsightsCount: Number
2020
)
2121

src/main/kotlin/org/digma/intellij/plugin/ui/jcef/model/SetInsightStatsMessage.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ data class SetInsightStatsMessage(val payload: SetInsightStatsMessagePayload) {
1212
data class SetInsightStatsMessagePayload(
1313
val scope: JsonNode?,
1414
val analyticsInsightsCount: Number,
15-
val issuesInsightsCount: Number,
16-
val unreadInsightsCount: Number
15+
val totalQueryResultCount: Number,
16+
val unreadInsightsCount: Number,
17+
val criticalInsightsCount: Number,
18+
val allIssuesCount: Number
1719
)

src/main/resources/webview/main/index.js

Lines changed: 207 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)