Skip to content

Commit

Permalink
Performance enhancement to file fetching
Browse files Browse the repository at this point in the history
Signed-off-by: Liam Barry Allan <[email protected]>
  • Loading branch information
worksofliam committed Oct 26, 2022
1 parent 2d170cd commit a85cd06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 8 additions & 5 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,21 @@ export function activate(context: ExtensionContext) {
parts.table = table;
}

await commands.executeCommand(`code-for-ibmi.runCommand`, {
const outfileRes: any = await commands.executeCommand(`code-for-ibmi.runCommand`, {
environment: `ile`,
command: `DSPFFD FILE(${parts.schema}/${parts.table}) OUTPUT(*OUTFILE) OUTFILE(${fullPath})`
});

console.log(`Temp OUTFILE created.`);
console.log(outfileRes);
const resultCode = outfileRes.code || 0;

const data: object[] = await content.getTable(config.tempLibrary, randomFile);
if (resultCode === 0) {
const data: object[] = await content.getTable(config.tempLibrary, randomFile);

console.log(`Temp OUTFILE read. ${data.length} rows.`);
console.log(`Temp OUTFILE read. ${data.length} rows.`);

return data;
return data;
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion server/src/language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class Parser {
if (name.trim() === ``) return [];
if (!this.tableFetch) return [];
const table = name.toUpperCase();
const existingVersion = table + keyVersion;
const existingVersion = table;
const now = Date.now();

if (this.tables[existingVersion]) {
Expand Down Expand Up @@ -95,6 +95,11 @@ export default class Parser {
recordFormats: newDefs
};
} catch (e) {
// Failed. Don't fetch it again
this.tables[existingVersion] = {
fetched: now,
recordFormats: []
};
newDefs = [];
}

Expand Down

0 comments on commit a85cd06

Please sign in to comment.