Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOQL and DML Count implemented without aggregation🔄 #10

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 48 additions & 14 deletions src/modules/main/logFileProcessor/logFileProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export default class LogFileProcessor extends LightningElement {
stdExpCount = 0;
codeUnitsCount = 0;
methodUnitsCount = 0;
soqlCount = 0;
dmlCount = 0;
eventsPicklistValues = new Set();
execAnonyCount = 0;
fileData;
Expand All @@ -85,7 +87,9 @@ export default class LogFileProcessor extends LightningElement {
nofLines: 0,
nofCodeUnits: 0,
nofMethodUnits: 0,
errors: []
errors: [],
soqlCount: 0,
dmlCount: 0
};
fileDataPartial = [];
// @wire(MessageContext)
Expand Down Expand Up @@ -115,6 +119,8 @@ export default class LogFileProcessor extends LightningElement {
reader.readAsText(rawFile);
}
processLogData() {
let isSoql = false;
let isDml = false;
this.fileData.forEach((line, idx) => {
if (this.STD_EXP_MATCHER.test(line)) {
this.stdExpCount++;
Expand All @@ -128,13 +134,6 @@ export default class LogFileProcessor extends LightningElement {
const RegexMap = eventsRegexMain.get(lineEvent);
for (let [key, value] of RegexMap) {
if (key.test(line)) {
// console.log(
// value,
// '=>',
// key.test(line),
// '=>',
// line
// );
this.createCodeUnit(line, value, idx + 1);
break;
}
Expand Down Expand Up @@ -183,8 +182,16 @@ export default class LogFileProcessor extends LightningElement {
errStr
);
}
} else if (lineEvent === 'SOQL_EXECUTE_BEGIN') {
this.soqlCount++;
isSoql = true;
} else if (lineEvent === 'DML_BEGIN') {
this.dmlCount++;
isDml = true;
}
this.addLinetoCUorMU(line, lineEvent, idx);
this.addLinetoCUorMU(line, lineEvent, idx, isSoql, isDml);
isDml = false;
isSoql = false;
}

this.addToFileDataPartial(line, lineEvent, idx + 1);
Expand Down Expand Up @@ -219,6 +226,8 @@ export default class LogFileProcessor extends LightningElement {
// console.log('Type: ', type);
let cu = {};
cu.unitDuration = index;
cu.soqlCount = 0;
cu.dmlCount = 0;
if (type === 'Class-Action') {
enteredCondition = true;
const splitArr = line.split('|');
Expand Down Expand Up @@ -338,6 +347,8 @@ export default class LogFileProcessor extends LightningElement {
*/
let methodUnit = {};
methodUnit.unitDuration = index;
methodUnit.soqlCount = 0;
methodUnit.dmlCount = 0;
if (type === 'Method-Generic') {
this.isCurUnitCU = false;
this.methodUnitsCount++;
Expand All @@ -357,15 +368,15 @@ export default class LogFileProcessor extends LightningElement {
.substring(methodUnit.methodTitle.lastIndexOf('.') + 1) +
s2;
//Once methodUnit fields are filled push it to methodUnitsStack
this.addMUtoResult(methodUnit);
this.addMUorLinetoResult(methodUnit);
this.methodUnitsStack.push(methodUnit);
} else if (type === 'Method-System') {
this.isCurUnitCU = false;
// methodUnit.Id = this.methodUnitsCount++;
methodUnit.methodTitle = 'System Method';
methodUnit.type = 'System Method';
methodUnit.methodName = line.substring(line.lastIndexOf('|') + 1);
this.addMUtoResult(methodUnit);
this.addMUorLinetoResult(methodUnit);
this.methodUnitsStack.push(methodUnit);
}
methodUnit.startTime = this.extractTimeStamp(line);
Expand Down Expand Up @@ -393,7 +404,7 @@ export default class LogFileProcessor extends LightningElement {
return this.codeUnitsStack[this.codeUnitsStack.length - 1];
}

addMUtoResult(methodUnit) {
addMUorLinetoResult(methodUnit, isSoql, isDml) {
//check if methodUnitsStack is empty
if (this.methodUnitsStack.length !== 0) {
let MUTop = this.currentMU();
Expand All @@ -403,6 +414,16 @@ export default class LogFileProcessor extends LightningElement {
MUTop.childUnitsandLines = [];
MUTop.childUnitsandLines.push(methodUnit);
}
if (isSoql) {
let count = MUTop.soqlCount + 1;
MUTop.soqlCount = count;
// console.log(MUTop);
}
if (isDml) {
let count = MUTop.soqlCount + 1;
MUTop.dmlCount = count;
// console.log(MUTop);
}
} else if (this.codeUnitsStack.length !== 0) {
let CUTop = this.currentCU();
if (CUTop.childUnitsandLines) {
Expand All @@ -411,6 +432,16 @@ export default class LogFileProcessor extends LightningElement {
CUTop.childUnitsandLines = [];
CUTop.childUnitsandLines.push(methodUnit);
}
if (isSoql) {
let count = CUTop.soqlCount + 1;
CUTop.soqlCount = count;
// console.log(CUTop);
}
if (isDml) {
let count = CUTop.dmlCount + 1;
CUTop.dmlCount = count;
// console.log(CUTop);
}
}
}

Expand All @@ -434,9 +465,9 @@ export default class LogFileProcessor extends LightningElement {
}
}

addLinetoCUorMU(line, event, idx) {
addLinetoCUorMU(line, event, idx, isSoql, isDml) {
let lineDetails = { line: line, event: event, lineNumber: idx };
this.addMUtoResult(lineDetails);
this.addMUorLinetoResult(lineDetails, isSoql, isDml);
}

addToFileDataPartial(line, event, lineNumber) {
Expand All @@ -453,6 +484,9 @@ export default class LogFileProcessor extends LightningElement {
this.fileMetadata.nofMethodUnits = this.methodUnitsCount;
this.fileMetadata.nofLines = this.fileData.length;
this.fileMetadata.errors = this.errors;
this.fileMetadata.soqlCount = this.soqlCount;
this.fileMetadata.dmlCount = this.dmlCount;

// console.log("Event Picklist Values: ", this.eventsPicklistValues);
const payload = {
fileMetadata: this.fileMetadata,
Expand Down
38 changes: 35 additions & 3 deletions src/modules/main/logViewer/logViewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ <h1>
<li>
<div
class="metricsElement metricsTitle"
title="Total Records"
title="Total
Lines"
>
Total
Lines
Expand All @@ -669,7 +670,8 @@ <h1>
<li>
<div
class="metricsElement metricsTitle"
title="Total Annual Revenue"
title="Total
CodeUnits"
>
Total
CodeUnits
Expand All @@ -683,7 +685,8 @@ <h1>
<li>
<div
class="metricsElement metricsTitle"
title="Total Partner Account"
title="Total
MethodUnits"
>
Total
MethodUnits
Expand All @@ -694,6 +697,35 @@ <h1>
{fileMetadata.nofMethodUnits}
</div>
</li>
<li>
<div
class="metricsElement metricsTitle"
title="SQOL Queries"
>
SQOL
Queries
</div>
<div
class="metricsElement metricsValue"
>
{fileMetadata.soqlCount}
</div>
</li>
<li>
<div
class="metricsElement metricsTitle"
title="DML
Operations"
>
DML
Operations
</div>
<div
class="metricsElement metricsValue"
>
{fileMetadata.dmlCount}
</div>
</li>
</ul>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/modules/main/logViewer/logViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export default class logViewer extends LightningElement {
fileName: '',
nofLines: 0,
nofCodeUnits: 0,
nofMethodUnits: 0
nofMethodUnits: 0,
soqlCount: 0,
dmlCount: 0
};
noOfPages = 0;
pageNumber = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/modules/parser/callTree/callTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ function parseDebugLogUnits(obj, units = [], level = 1, parentId) {
type: obj.cuType,
name: obj.cuName,
timeInMS: timeInMS,
dmlCount: obj.dmlCount,
soqlCount: obj.soqlCount,
level: level,
unitDuration: obj.unitDuration,
unitLength: duration,
Expand Down Expand Up @@ -181,6 +183,8 @@ function parseDebugLogUnits(obj, units = [], level = 1, parentId) {
timeInMS: timeInMS,
type: obj.type,
level: level,
dmlCount: obj.dmlCount,
soqlCount: obj.soqlCount,
unitDuration: obj.unitDuration,
unitLength: duration,
hasChild: Object.values(obj).some(hasChildUnits)
Expand Down
Loading