Skip to content

Commit

Permalink
Revert the log to show newest first
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyiliev committed Oct 26, 2023
1 parent d5055b3 commit 224ad20
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/providers/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default class ActivityLogTreeProvider implements vscode.TreeDataProvider<

getChildren(element?: ActivityLogNode): Thenable<ActivityLogNode[]> {
if (!element) {
return Promise.resolve(this.logs.map(log => new ActivityLogNode(log)));
// Revert the logs to show the newest ones at the top
return Promise.resolve(this.logs.slice().reverse().map(log => new ActivityLogNode(log)));
}
return Promise.resolve([]);
}
Expand All @@ -34,9 +35,14 @@ interface ActivityLog {

class ActivityLogItem extends vscode.TreeItem {
constructor(public readonly log: ActivityLog) {
super(log.sql, vscode.TreeItemCollapsibleState.None);
this.description = `${log.status === "success" ? "✅" : "❌"} | Latency: ${log.latency}ms`;
this.tooltip = log.sql;
// Shorten the displayed query if it's too long
const shortSQL = log.sql.length > 50 ? log.sql.substring(0, 50) + "..." : log.sql;
super(`${log.status === "success" ? "✅" : "❌"} ${shortSQL}`, vscode.TreeItemCollapsibleState.None);

// Update the description to display latency with a stopwatch emoji.
this.description = `⏱️ ${log.latency}ms`;

this.tooltip = `${log.sql} | Latency: ${log.latency}ms`;
this.contextValue = 'activityLogItem';

// Copy SQL command to clipboard
Expand Down

0 comments on commit 224ad20

Please sign in to comment.