Skip to content

Commit 1ba2dc2

Browse files
committed
refactor: remove totals nesting on governorlimits interface
Make it easier to access and makes more sense.
1 parent 56dbd57 commit 1ba2dc2

4 files changed

Lines changed: 41 additions & 46 deletions

File tree

log-viewer/modules/__tests__/ApexLogParser.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,9 +1162,9 @@ describe('Governor Limits Parsing', () => {
11621162
const apexLog = parse(log);
11631163

11641164
expect(apexLog.governorLimits).toBeDefined();
1165-
expect([...apexLog.governorLimits.limitsByNamespace.keys()]).toEqual(['default', 'myNS']);
1165+
expect([...apexLog.governorLimits.byNamespace.keys()]).toEqual(['default', 'myNS']);
11661166

1167-
expect(apexLog.governorLimits.limitsByNamespace.get('default')).toMatchObject({
1167+
expect(apexLog.governorLimits.byNamespace.get('default')).toMatchObject({
11681168
soqlQueries: { used: 17, limit: 100 },
11691169
queryRows: { used: 121, limit: 50000 },
11701170
soslQueries: { used: 3, limit: 20 },
@@ -1180,7 +1180,7 @@ describe('Governor Limits Parsing', () => {
11801180
mobileApexPushCalls: { used: 1, limit: 10 },
11811181
});
11821182

1183-
expect(apexLog.governorLimits.limitsByNamespace.get('myNS')).toMatchObject({
1183+
expect(apexLog.governorLimits.byNamespace.get('myNS')).toMatchObject({
11841184
soqlQueries: { used: 2, limit: 100 },
11851185
queryRows: { used: 10, limit: 50000 },
11861186
soslQueries: { used: 1, limit: 20 },
@@ -1196,7 +1196,7 @@ describe('Governor Limits Parsing', () => {
11961196
mobileApexPushCalls: { used: 0, limit: 10 },
11971197
});
11981198

1199-
expect(apexLog.governorLimits.totals).toMatchObject({
1199+
expect(apexLog.governorLimits).toMatchObject({
12001200
soqlQueries: { used: 19, limit: 100 },
12011201
queryRows: { used: 131, limit: 50000 },
12021202
soslQueries: { used: 4, limit: 20 },
@@ -1241,8 +1241,8 @@ describe('Governor Limits Parsing', () => {
12411241
queueableJobsAddedToQueue: { used: 0, limit: 0 },
12421242
mobileApexPushCalls: { used: 0, limit: 0 },
12431243
};
1244-
expect(apexLog.governorLimits.limitsByNamespace.get('default')).toMatchObject(expected);
1245-
expect(apexLog.governorLimits.totals).toMatchObject(expected);
1244+
expect(apexLog.governorLimits.byNamespace.get('default')).toMatchObject(expected);
1245+
expect(apexLog.governorLimits).toMatchObject(expected);
12461246
});
12471247
});
12481248

log-viewer/modules/components/calltree-view/CalltreeView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ export class CalltreeView extends LitElement {
567567
const namespaceFilterCache = new Map<string, boolean>();
568568

569569
const excludedTypes = new Set<LogEventType>(['SOQL_EXECUTE_BEGIN', 'DML_BEGIN']);
570-
const governorLimits = rootMethod.governorLimits.totals;
570+
const governorLimits = rootMethod.governorLimits;
571571

572572
let childIndent;
573573
this.calltreeTable = new Tabulator(callTreeTableContainer, {

log-viewer/modules/parsers/ApexLogParser.ts

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,20 @@ export class ApexLogParser {
4343
discontinuity = false;
4444
namespaces = new Set<string>();
4545
governorLimits: GovernorLimits = {
46-
totals: {
47-
soqlQueries: { used: 0, limit: 0 },
48-
soslQueries: { used: 0, limit: 0 },
49-
queryRows: { used: 0, limit: 0 },
50-
dmlStatements: { used: 0, limit: 0 },
51-
publishImmediateDml: { used: 0, limit: 0 },
52-
dmlRows: { used: 0, limit: 0 },
53-
cpuTime: { used: 0, limit: 0 },
54-
heapSize: { used: 0, limit: 0 },
55-
callouts: { used: 0, limit: 0 },
56-
emailInvocations: { used: 0, limit: 0 },
57-
futureCalls: { used: 0, limit: 0 },
58-
queueableJobsAddedToQueue: { used: 0, limit: 0 },
59-
mobileApexPushCalls: { used: 0, limit: 0 },
60-
},
61-
limitsByNamespace: new Map<string, Limits>(),
46+
soqlQueries: { used: 0, limit: 0 },
47+
soslQueries: { used: 0, limit: 0 },
48+
queryRows: { used: 0, limit: 0 },
49+
dmlStatements: { used: 0, limit: 0 },
50+
publishImmediateDml: { used: 0, limit: 0 },
51+
dmlRows: { used: 0, limit: 0 },
52+
cpuTime: { used: 0, limit: 0 },
53+
heapSize: { used: 0, limit: 0 },
54+
callouts: { used: 0, limit: 0 },
55+
emailInvocations: { used: 0, limit: 0 },
56+
futureCalls: { used: 0, limit: 0 },
57+
queueableJobsAddedToQueue: { used: 0, limit: 0 },
58+
mobileApexPushCalls: { used: 0, limit: 0 },
59+
byNamespace: new Map<string, Limits>(),
6260
};
6361

6462
/**
@@ -82,9 +80,9 @@ export class ApexLogParser {
8280
}
8381

8482
private addGovernorLimits(apexLog: ApexLog) {
85-
const totalLimits = apexLog.governorLimits.totals;
83+
const totalLimits = apexLog.governorLimits;
8684
if (totalLimits) {
87-
for (const limitsForNs of apexLog.governorLimits.limitsByNamespace.values()) {
85+
for (const limitsForNs of apexLog.governorLimits.byNamespace.values()) {
8886
for (const [key, value] of Object.entries(limitsForNs) as Array<
8987
[keyof Limits, Limits[keyof Limits]]
9088
>) {
@@ -537,9 +535,8 @@ export interface Limits {
537535
mobileApexPushCalls: { used: number; limit: number };
538536
}
539537

540-
export interface GovernorLimits {
541-
totals: Limits;
542-
limitsByNamespace: Map<string, Limits>;
538+
export interface GovernorLimits extends Limits {
539+
byNamespace: Map<string, Limits>;
543540
}
544541
/**
545542
* All log lines extend this base class.
@@ -879,22 +876,20 @@ export class ApexLog extends Method {
879876
public parsingErrors: string[] = [];
880877

881878
public governorLimits: GovernorLimits = {
882-
totals: {
883-
soqlQueries: { used: 0, limit: 0 },
884-
soslQueries: { used: 0, limit: 0 },
885-
queryRows: { used: 0, limit: 0 },
886-
dmlStatements: { used: 0, limit: 0 },
887-
publishImmediateDml: { used: 0, limit: 0 },
888-
dmlRows: { used: 0, limit: 0 },
889-
cpuTime: { used: 0, limit: 0 },
890-
heapSize: { used: 0, limit: 0 },
891-
callouts: { used: 0, limit: 0 },
892-
emailInvocations: { used: 0, limit: 0 },
893-
futureCalls: { used: 0, limit: 0 },
894-
queueableJobsAddedToQueue: { used: 0, limit: 0 },
895-
mobileApexPushCalls: { used: 0, limit: 0 },
896-
},
897-
limitsByNamespace: new Map<string, Limits>(),
879+
soqlQueries: { used: 0, limit: 0 },
880+
soslQueries: { used: 0, limit: 0 },
881+
queryRows: { used: 0, limit: 0 },
882+
dmlStatements: { used: 0, limit: 0 },
883+
publishImmediateDml: { used: 0, limit: 0 },
884+
dmlRows: { used: 0, limit: 0 },
885+
cpuTime: { used: 0, limit: 0 },
886+
heapSize: { used: 0, limit: 0 },
887+
callouts: { used: 0, limit: 0 },
888+
emailInvocations: { used: 0, limit: 0 },
889+
futureCalls: { used: 0, limit: 0 },
890+
queueableJobsAddedToQueue: { used: 0, limit: 0 },
891+
mobileApexPushCalls: { used: 0, limit: 0 },
892+
byNamespace: new Map<string, Limits>(),
898893
};
899894

900895
/**
@@ -1653,7 +1648,7 @@ class LimitUsageForNSLine extends LogLine {
16531648
}
16541649
}
16551650

1656-
parser.governorLimits.limitsByNamespace.set(this.namespace, limits);
1651+
parser.governorLimits.byNamespace.set(this.namespace, limits);
16571652
}
16581653
}
16591654

log-viewer/modules/timeline/Timeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ function findTimelineTooltip(
676676
rows.push({ label: 'total:', value: val });
677677
}
678678

679-
const govLimits = timelineRoot.governorLimits.totals;
679+
const govLimits = timelineRoot.governorLimits;
680680
if (target.dmlCount.total) {
681681
rows.push({
682682
label: 'DML:',

0 commit comments

Comments
 (0)