Skip to content

Commit

Permalink
fix: get log query for specific number of logs and descending order (#83
Browse files Browse the repository at this point in the history
)

@W-8331099@, @W-8331134@
  • Loading branch information
lcampos committed Nov 5, 2020
1 parent 4b21548 commit 4d963d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/apex-node/src/logs/logService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ export class LogService {
public async getLogRecords(numberOfLogs?: number): Promise<LogRecord[]> {
let query = 'Select Id, Application, DurationMilliseconds, Location, ';
query +=
'LogLength, LogUser.Name, Operation, Request, StartTime, Status from ApexLog Order By StartTime';
'LogLength, LogUser.Name, Operation, Request, StartTime, Status from ApexLog Order By StartTime DESC';

if (typeof numberOfLogs === 'number') {
if (numberOfLogs <= 0) {
throw new Error(nls.localize('num_logs_error'));
}
numberOfLogs = Math.min(numberOfLogs, MAX_NUM_LOGS);
query += `DESC LIMIT ${numberOfLogs}`;
query += ` LIMIT ${numberOfLogs}`;
}

const response = (await this.connection.tooling.query(
Expand Down
6 changes: 3 additions & 3 deletions packages/apex-node/test/logs/logService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ describe('Apex Log Service Tests', () => {
const numberOfLogs = 2;
let query = 'Select Id, Application, DurationMilliseconds, Location, ';
query +=
'LogLength, LogUser.Name, Operation, Request, StartTime, Status from ApexLog Order By StartTime';
query += `DESC LIMIT ${numberOfLogs}`;
'LogLength, LogUser.Name, Operation, Request, StartTime, Status from ApexLog Order By StartTime DESC ';
query += `LIMIT ${numberOfLogs}`;
const queryStub = sandboxStub
.stub(mockConnection.tooling, 'query')
//@ts-ignore
Expand All @@ -284,7 +284,7 @@ describe('Apex Log Service Tests', () => {
it('should return all log records', async () => {
let query = 'Select Id, Application, DurationMilliseconds, Location, ';
query +=
'LogLength, LogUser.Name, Operation, Request, StartTime, Status from ApexLog Order By StartTime';
'LogLength, LogUser.Name, Operation, Request, StartTime, Status from ApexLog Order By StartTime DESC';
const queryStub = sandboxStub
.stub(mockConnection.tooling, 'query')
//@ts-ignore
Expand Down

0 comments on commit 4d963d9

Please sign in to comment.