Skip to content

Commit a426bff

Browse files
authored
Merge pull request #238 from digma-ai/removing_duplicate_insights
Removing duplicate insights
2 parents ac4201e + e9f2b6a commit a426bff

File tree

6 files changed

+39
-15
lines changed

6 files changed

+39
-15
lines changed

src/analyticsCodeLens.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
109109
command: CodelensProvider.clickCommand,
110110
arguments: [methodInfo, insight.environment]
111111
}));
112-
112+
113113
}
114+
115+
114116
}
115117

116118
return lens;
@@ -181,7 +183,6 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
181183
if(!documentInfo)
182184
return [];
183185

184-
185186
const codelens: vscode.CodeLens[] = [];
186187
for(let methodInfo of documentInfo.methods)
187188
{
@@ -196,6 +197,16 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
196197
codelens.push(lens);
197198
}
198199

200+
if (lenses.length===0 && thisEnvInsights.length>0){
201+
codelens.push(new vscode.CodeLens(methodInfo.range, {
202+
title: "Runtime data",
203+
tooltip: "Click to see this function's runtime data",
204+
command: CodelensProvider.clickCommand,
205+
arguments: [methodInfo, this._state.environment]
206+
}));
207+
208+
209+
}
199210

200211
}
201212

@@ -222,9 +233,11 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
222233
}
223234

224235
const endpoints = documentInfo.endpoints.filter(e => e.range.intersection(methodInfo.range) != undefined);
225-
if(endpoints.length>0){
236+
const uniqueEndpoints = [...new Map(endpoints.map(item =>
237+
[item.id, item])).values()];
238+
if(uniqueEndpoints.length>0){
226239
const lenses = await this.getLensForCodeLocationObject(methodInfo,
227-
endpoints,documentInfo.usageData.getAll(),documentInfo.insights.all.filter(x=>x.scope=="EntrySpan"|| x.scope=="Span"),
240+
uniqueEndpoints,documentInfo.usageData.getAll(),documentInfo.insights.all.filter(x=>x.scope=="EntrySpan"|| x.scope=="Span"),
228241
);
229242

230243
for (const lens of lenses){
@@ -254,6 +267,8 @@ class CodelensProvider implements vscode.CodeLensProvider<vscode.CodeLens>
254267

255268
}
256269

270+
271+
257272
return codelens;
258273
}
259274

src/services/analyticsProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ export interface CodeObjectUsageStatus {
236236
environment: string;
237237
type: string;
238238
name: string;
239+
groupName: string;
239240
codeObjectId: string;
240241
lastRecordedTime: moment.Moment;
241242
firstRecordedTime: moment.Moment;

src/services/documentInfoProvider.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,13 @@ export class DocumentInfoProvider implements vscode.Disposable
203203
.filter(x=>x.scope=="EntrySpan" && x.route)
204204
.filter(x=>!endpoints.any(e=>e.id===x.codeObjectId));
205205

206-
const uniqueEndpoints = [...new Map(endPointsDiscoveredViaServer.map(item =>
207-
[item.codeObjectId, item])).values()];
206+
// const uniqueEndpoints = [...new Map(endPointsDiscoveredViaServer.map(item =>
207+
// [item.codeObjectId, item])).values()];
208208

209+
const uniqueEndpoints = [...new Map(endPointsDiscoveredViaServer.map(item =>
210+
[item.route, item])).values()];
209211
for ( const endpoint of uniqueEndpoints){
210-
212+
211213
if (endpoint.route){
212214

213215
const shortRouteName = EndpointSchema.getShortRouteName(endpoint.route);
@@ -581,7 +583,9 @@ export class CodeObjectInsightsAccessor{
581583
if (environment){
582584
insights = insights.filter(x=>x.environment===environment);
583585
}
584-
return insights;
586+
const uniqueInsights = [...new Map(insights.map(item =>
587+
[item.type, item])).values()];
588+
return uniqueInsights;
585589

586590
}
587591
public get all(): CodeObjectInsight[]{

src/views/ListView/IListViewItem.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ export class InsightListGroupItemsRenderer implements IItemsInGroup
6464
return this.group.getHtml() + html;
6565

6666
}
67-
else if (this.emptyGroupItemtemplate){
68-
html+=this.emptyGroupItemtemplate.getHtml();
69-
return this.group.getHtml() + html;
70-
}
67+
// else if (this.emptyGroupItemtemplate){
68+
// html+=this.emptyGroupItemtemplate.getHtml();
69+
// return this.group.getHtml() + html;
70+
// }
7171
return html;
7272

7373
//+ this.codeObjectEnvironments.getUsageHtml(this.group.groupId, this.group.type, this.usageResults )

src/views/codeAnalytics/CodeObjectGroups/CodeObjectGroupDiscovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class CodeObjectGroupDiscovery{
1212
const statusesByType =codeObjectUsagesStatus.groupBy(x=>x.type);
1313
const types = Object.keys(statusesByType);
1414
for (const type of types){
15-
const constObjectsData = statusesByType[type].map(x=>x.name);
15+
const constObjectsData = statusesByType[type].map(x=>x.groupName);
1616
const uniqueCodeObjects = [... new Set(constObjectsData)]
1717
for (const codeObjectGroup of uniqueCodeObjects){
1818
const groupItem = await this._groupViewItemCreator.create(type, codeObjectGroup);

src/views/codeAnalytics/CodeObjectGroups/EndpointGroup.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ export class HttpEndpointGroup {
3939

4040
const shortRouteName = EndpointSchema.getShortRouteName(name);
4141
const parts = shortRouteName.split(' ');
42+
var offset =1;
43+
if (parts.length==3){
44+
offset=0;
45+
}
4246

4347
return new GroupItem(shortRouteName, type, `
4448
<div class="group-item">
4549
<span class="codicon codicon-symbol-interface" title="Endpoint"></span>
4650
<span class="uppercase">
47-
<strong>HTTP </strong>${parts[0]}&nbsp;</span>
48-
<span>${parts[1]}</span>
51+
<strong>HTTP </strong>${parts[1-offset]}&nbsp;</span>
52+
<span>${parts[2-offset]}</span>
4953
</div>
5054
`);
5155
}

0 commit comments

Comments
 (0)