Skip to content

Commit 5859492

Browse files
Fix insights caching issue
1 parent c1794a6 commit 5859492

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/insights/InsightsProvider.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,15 @@ public InsightsProvider(Project project) {
3636
this.project = project;
3737
}
3838

39-
public InsightsListContainer getInsights(@NotNull MethodInfo methodInfo) {
39+
public InsightsListContainer getUpdatedInsightsList(@NotNull MethodInfo methodInfo) {
4040
List<? extends CodeObjectInsight> upToDateInsightsList;
4141
List<String> objectIds = getObjectIds(methodInfo);
4242
Log.log(LOGGER::debug, "Got following code object ids for method {}: {}", methodInfo.getId(), objectIds);
4343
var stopWatch = StopWatch.createStarted();
4444
try {
45-
upToDateInsightsList = analyticsService.getInsights(objectIds);
46-
} catch (AnalyticsServiceException e) {
47-
//if analyticsService.getInsights throws exception it means insights could not be loaded, usually when
48-
//the backend is not available. return an empty InsightsListContainer to keep everything running and don't
49-
//crash the plugin. don't log the exception, it was logged in AnalyticsService, keep the log quite because
50-
//it may happen many times.
51-
Log.log(LOGGER::debug, "AnalyticsServiceException for getInsights for {}: {}", methodInfo.getId(), e.getMessage());
52-
return new InsightsListContainer();
45+
//refresh insights cache
46+
documentInfoService.refreshAll();
47+
upToDateInsightsList = documentInfoService.getCachedMethodInsights(methodInfo);
5348
} finally {
5449
stopWatch.stop();
5550
Log.log(LOGGER::debug, "getInsights time took {} milliseconds", stopWatch.getTime(TimeUnit.MILLISECONDS));

ide-common/src/main/kotlin/org/digma/intellij/plugin/ui/service/InsightsViewService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class InsightsViewService(project: Project) : AbstractViewService(project) {
173173
val scope = model.scope
174174
if (scope is MethodScope) {
175175
Backgroundable.ensureBackground(project, "Refresh insights list") {
176-
updateInsightsModel(scope.getMethodInfo(), insightsProvider.getInsights(scope.getMethodInfo()))
176+
updateInsightsModel(scope.getMethodInfo(), insightsProvider.getUpdatedInsightsList(scope.getMethodInfo()))
177177
}
178178
}
179179
}

0 commit comments

Comments
 (0)