Skip to content

Commit f7cd107

Browse files
authored
Merge pull request #2407 from digma-ai/feature/service-filters
Feature/service filters
2 parents ed1d348 + 0d1e17f commit f7cd107

File tree

7 files changed

+67
-42
lines changed

7 files changed

+67
-42
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public String register(@NotNull Map<String, Object> queryParams) throws Analytic
462462
}
463463

464464
@NotNull
465-
public InsightsStatsResult getInsightsStats(String spanCodeObjectId, String insightTypes) {
465+
public InsightsStatsResult getInsightsStats(String spanCodeObjectId, String insightTypes, String services) {
466466
try {
467467
var envId = getCurrentEnvironmentId();
468468
var params = new HashMap<String, Object>();
@@ -476,6 +476,10 @@ public InsightsStatsResult getInsightsStats(String spanCodeObjectId, String insi
476476
params.put("insights", insightTypes);
477477
}
478478

479+
if (services != null && !services.isEmpty()) {
480+
params.put("services", services);
481+
}
482+
479483
return executeCatching(() -> analyticsProviderProxy.getInsightsStats(params));
480484
} catch (Exception e) {
481485
Log.debugWithException(LOGGER, project, e, "error calling insights stats", e.getMessage());

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
@@ -167,7 +167,7 @@ class ScopeManager(private val project: Project) {
167167

168168
//in both these cases, if there are no insights, show analytics
169169
if (preferredView == null || preferredView == View.Insights) {
170-
val insightsStats = AnalyticsService.getInstance(project).getInsightsStats(scope.spanCodeObjectId, null)
170+
val insightsStats = AnalyticsService.getInstance(project).getInsightsStats(scope.spanCodeObjectId, null, null)
171171
if (insightsStats.issuesInsightsCount == 0) {
172172
MainContentViewSwitcher.getInstance(project).showAnalytics()
173173
} else {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ data class GetIssuesRequestPayload
1717
"sortBy",
1818
"sortOrder",
1919
"insightTypes",
20+
"services",
2021
"page"
2122
)
2223
constructor(
@@ -28,5 +29,6 @@ constructor(
2829
val sortBy: String,
2930
val sortOrder: String,
3031
@JsonRawValue val insightTypes: String?,
32+
@JsonRawValue val services: String?,
3133
val page: Number
3234
)

src/main/java/org/digma/intellij/plugin/insights/AbstractInsightsMessageRouterHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ private void pushIssuesListData(JsonNode jsonNode) throws JsonProcessingExceptio
9999
query.at("/sorting/criterion").asText(null),
100100
query.at("/sorting/order").asText(null),
101101
query.at("/insightTypes").toString(),
102+
query.at("/services").toString(),
102103
query.at("/page").asInt(0));
103104

104105
InsightsService.getInstance(getProject()).refreshIssuesList(request);

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,23 @@ abstract class BaseMessageRouterHandler(protected val project: Project) : Common
270270
payload?.let {
271271
val scopeNode = payload.get("scope")
272272
val insightTypesJsonArray = payload.at("/filters/insights")
273+
val servicesJsonArray = payload.at("/filters/services")
273274
val insightTypes = mutableListOf<String>()
274275
if (insightTypesJsonArray is ArrayNode) {
275276
insightTypesJsonArray.forEach { type: JsonNode ->
276277
insightTypes.add(type.asText())
277278
}
278279
}
280+
val services = mutableListOf<String>()
281+
if (servicesJsonArray is ArrayNode) {
282+
servicesJsonArray.forEach { type: JsonNode ->
283+
services.add(type.asText())
284+
}
285+
}
279286
if (scopeNode is NullNode) {
280-
val stats = AnalyticsService.getInstance(project).getInsightsStats(null, insightTypes.joinToString())
287+
val stats =
288+
AnalyticsService.getInstance(project)
289+
.getInsightsStats(null, insightTypes.joinToString(","), services.joinToString(","))
281290
project.messageBus.syncPublisher(InsightStatsChangedEvent.INSIGHT_STATS_CHANGED_TOPIC)
282291
.insightStatsChanged(
283292
null,
@@ -289,7 +298,8 @@ abstract class BaseMessageRouterHandler(protected val project: Project) : Common
289298
)
290299
} else {
291300
val spanCodeObjectId = scopeNode.get("span").get("spanCodeObjectId").asText()
292-
val stats = AnalyticsService.getInstance(project).getInsightsStats(spanCodeObjectId, insightTypes.joinToString())
301+
val stats = AnalyticsService.getInstance(project)
302+
.getInsightsStats(spanCodeObjectId, insightTypes.joinToString(","), services.joinToString(","))
293303
project.messageBus.syncPublisher(InsightStatsChangedEvent.INSIGHT_STATS_CHANGED_TOPIC)
294304
.insightStatsChanged(
295305
scopeNode,
@@ -377,7 +387,7 @@ abstract class BaseMessageRouterHandler(protected val project: Project) : Common
377387
Log.debugWithException(logger, project, e, "error calling about")
378388
}
379389

380-
val insightsStats = AnalyticsService.getInstance(project).getInsightsStats(null, null)
390+
val insightsStats = AnalyticsService.getInstance(project).getInsightsStats(null, null, null)
381391

382392
updateDigmaEngineStatus(project, browser)
383393

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private constructor(
269269
scope: SpanScope?, codeLocation: CodeLocation, hasErrors: Boolean, scopeContext: ScopeContext?, environmentId: String?
270270
) {
271271
try {
272-
val insightsStats = AnalyticsService.getInstance(project).getInsightsStats(scope?.spanCodeObjectId, null)
272+
val insightsStats = AnalyticsService.getInstance(project).getInsightsStats(scope?.spanCodeObjectId, null, null)
273273

274274
sendScopeChangedMessage(
275275
jbCefBrowser.cefBrowser,

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

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

0 commit comments

Comments
 (0)