Skip to content

Commit 783335d

Browse files
fixed normalize bug + other stuff
1 parent cc23722 commit 783335d

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

vscode-trace-extension/src/csv-download/csv-download.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'path';
55
import { getTspClient } from "../utils/backend-tsp-client-provider";
66
import { QueryHelper } from "tsp-typescript-client";
77

8-
export const exportCSV = async (outputID: string = 'org.eclipse.tracecompass.internal.provisional.tmf.core.model.events.TmfEventTableDataProvider') => {
8+
export const exportCSV = async (outputID: string) => {
99

1010
// Helper FUnctions
1111
const REQUEST_SIZE = 1000;
@@ -71,7 +71,7 @@ export const exportCSV = async (outputID: string = 'org.eclipse.tracecompass.int
7171

7272
try {
7373
// 1) Resolve headers
74-
progress.report({ message: 'Fetching column headers…', increment: 5 });
74+
progress.report({ message: 'Fetching column headers…', increment: 2 });
7575
// todo fix
7676
const headersResp = await tsp.fetchTableColumns(activeData.UUID, outputID, QueryHelper.query());
7777
const headersModel = headersResp.getModel()?.model;
@@ -82,11 +82,15 @@ export const exportCSV = async (outputID: string = 'org.eclipse.tracecompass.int
8282
const headerNames: string[] = headersModel.map((c: { name: string }) => c.name);
8383

8484
// 2) Compute absolute timestamps for selection
85-
const START_TIME = BigInt(absoluteRange.start) + BigInt(selectionRange.start);
86-
const END_TIME = BigInt(absoluteRange.start) + BigInt(selectionRange.end);
85+
const t1 = BigInt(absoluteRange.start) + BigInt(selectionRange.start);
86+
const t2 = BigInt(absoluteRange.start) + BigInt(selectionRange.end);
87+
88+
// Normalize
89+
const START_TIME = t1 < t2 ? t1 : t2;
90+
const END_TIME = t1 < t2 ? t2 : t1;
8791

8892
// 3) Resolve start/end indices by time (like your POC)
89-
progress.report({ message: 'Resolving table indices…', increment: 10 });
93+
progress.report({ message: 'Resolving table indices…', increment: 2 });
9094

9195
const indexBody = (requestedTime: bigint) => ({
9296
requested_times: [requestedTime],
@@ -153,7 +157,7 @@ export const exportCSV = async (outputID: string = 'org.eclipse.tracecompass.int
153157
};
154158

155159
let processed = 0;
156-
progress.report({ message: `Exporting ${totalRows.toLocaleString()} rows…`, increment: 10 });
160+
progress.report({ message: `Exporting ${totalRows.toLocaleString()} rows…`, increment: 2 });
157161

158162
while (rowsLeft > 0 && !token.isCancellationRequested) {
159163
// Advance iterators for the *next* request before awaiting current
@@ -241,4 +245,4 @@ export const queryForOutputType = async () => {
241245

242246
return selection?.id;
243247

244-
}
248+
}

vscode-trace-extension/src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<Extern
132132
if (!outputID) {
133133
outputID = await queryForOutputType();
134134
}
135-
exportCSV(outputID);
135+
if (outputID) {
136+
exportCSV(outputID);
137+
}
136138
})
137139
);
138140

0 commit comments

Comments
 (0)