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

feat: lineage refactor #1212

Merged
merged 55 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
4bd8d9c
feat: lineage v2
saravmajestic Jun 13, 2024
b0d6aaa
fix: lineage interactions
saravmajestic Jun 13, 2024
fb048de
chore: help button
saravmajestic Jun 13, 2024
1da70b0
fix: action widget buttons
saravmajestic Jun 14, 2024
0bc6223
revert: unnecessary changes
saravmajestic Jun 14, 2024
b6ba6f1
chore: updated components
saravmajestic Jun 14, 2024
bee9382
fix: styles
saravmajestic Jun 14, 2024
d1fcb2d
Merge branch 'master' into feat/lineage-v2
saravmajestic Jun 14, 2024
9382b8f
fix: views code
saravmajestic Jun 14, 2024
da68973
Merge branch 'master' into feat/lineage-v2
saravmajestic Jun 17, 2024
e0c3649
fix: updated components
saravmajestic Jun 17, 2024
b4bbbc0
chore: cleanup
saravmajestic Jun 17, 2024
9fe65ea
chore: cleanup
saravmajestic Jun 17, 2024
13dcce1
Merge branch 'master' into feat/lineage-v2
saravmajestic Jul 8, 2024
fbec974
fix: static lineage integration
saravmajestic Jul 8, 2024
b3d8b2f
Merge branch 'master' into feat/lineage-v2
saravmajestic Jul 9, 2024
d7e3061
fix: merge issues
saravmajestic Jul 9, 2024
c8c38ad
fix: sql visualizer ui issues
saravmajestic Jul 9, 2024
2f82023
Merge branch 'feat/lineage-v2' of https://github.com/AltimateAI/vscod…
saravmajestic Jul 9, 2024
d82bd80
fix: update lib version
saravmajestic Jul 9, 2024
17e599b
fix: image cleanup
saravmajestic Jul 10, 2024
5143e9a
revert: lib changes
saravmajestic Jul 17, 2024
2df32ef
Merge branch 'master' into feat/lineage-v2
saravmajestic Jul 17, 2024
1aa310c
fix: lineage components (#1311)
AdiGajbhiye Jul 18, 2024
f9910a4
fix: update components
saravmajestic Jul 18, 2024
96be3e5
fix: minor issues
saravmajestic Jul 18, 2024
1ef1ba4
fix: expand popover ui
saravmajestic Jul 18, 2024
3eff7ba
fix: lineae demo
saravmajestic Jul 19, 2024
b5fde33
fix: lineage sidebar updates
saravmajestic Jul 19, 2024
6f6c6b6
fix: feedback btn for sql lineage
saravmajestic Jul 19, 2024
e2d7702
fix: code block type error
AdiGajbhiye Jul 19, 2024
c3a4989
fix: sql lineage render
AdiGajbhiye Jul 23, 2024
72c638b
fix: open url
AdiGajbhiye Jul 23, 2024
02e407e
feat: added final builds
AdiGajbhiye Jul 23, 2024
edf489a
feat: added final builds
AdiGajbhiye Jul 23, 2024
6284060
Merge branch 'master' into feat/lineage-v2
anandgupta42 Jul 24, 2024
c5fb15e
Merge branch 'master' into feat/lineage-v2
saravmajestic Jul 25, 2024
7f268e2
fix: default expansion
AdiGajbhiye Jul 31, 2024
8aa3e75
fix: reset
AdiGajbhiye Aug 5, 2024
dff48f1
Merge branch 'master' into feat/lineage-v2
AdiGajbhiye Aug 6, 2024
16232b1
Merge branch 'master' into feat/lineage-v2
saravmajestic Aug 13, 2024
f685076
Merge branch 'master' into feat/lineage-v2
saravmajestic Sep 23, 2024
67fd4f8
fix: ts error and update lib
saravmajestic Sep 24, 2024
ce8762d
fix: OOM
saravmajestic Sep 24, 2024
d27a9b8
Merge branch 'master' into feat/lineage-v2
AdiGajbhiye Oct 2, 2024
747de74
merge commit
AdiGajbhiye Oct 21, 2024
f2cdd96
fix: eslint warning
saravmajestic Oct 21, 2024
a28d423
fix: new lineage
AdiGajbhiye Oct 21, 2024
bbd65e4
feat: lineage migrated to v2
AdiGajbhiye Oct 21, 2024
3bcb5ae
fix: notification
AdiGajbhiye Oct 22, 2024
b2b4e73
feat: added build
AdiGajbhiye Oct 22, 2024
f182728
feat: saas init copied
AdiGajbhiye Oct 24, 2024
8519f62
fix: lineage render
saravmajestic Oct 24, 2024
ebdafe9
Merge branch 'master' into feat/lineage-v2
anandgupta42 Oct 28, 2024
c1c03fe
feat: updated build files
AdiGajbhiye Oct 28, 2024
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
2 changes: 1 addition & 1 deletion new_lineage_panel/src/service_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const openFile = (url: string) => {
};

export const openURL = (url: string) => {
vscode.postMessage({ command: "openURL", args: { url } });
vscode.postMessage({ command: "openURL", url });
};

export const openChat = () => openURL("https://app.myaltimate.com/contactus");
Expand Down
8 changes: 4 additions & 4 deletions src/altimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interface SQLLineageRequest {
session_id: string;
}

export type Details = Record<
export type SqlLineageDetails = Record<
string,
{
name: string;
Expand All @@ -90,9 +90,9 @@ export type Details = Record<
columns: { name: string; datatype?: string; expression?: string }[];
}
>;
type StaticLineageResponse = {
type SqlLineageResponse = {
tableEdges: [string, string][];
details: Details;
details: SqlLineageDetails;
nodePositions?: Record<string, [number, number]>;
};

Expand Down Expand Up @@ -933,7 +933,7 @@ export class AltimateRequest {
}

async sqlLineage(req: SQLLineageRequest) {
return this.fetch<StaticLineageResponse>("dbt/v3/sql_lineage", {
return this.fetch<SqlLineageResponse>("dbt/v3/sql_lineage", {
method: "POST",
body: JSON.stringify(req),
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ export class VSCodeCommands implements Disposable {
ViewColumn.Two,
{ retainContextWhenHidden: true, enableScripts: true },
);
this.sqlLineagePanel.resolveWebviewView(panel, lineage);
this.sqlLineagePanel.renderSqlVisualizer(panel, lineage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Incomplete method renaming detected.

The method resolveWebviewView still exists in multiple files, indicating that the renaming to renderSqlVisualizer was not fully propagated. To maintain code consistency and prevent potential issues, please ensure that all instances of resolveWebviewView are updated accordingly.

Affected files:

  • src/webview_provider/lineagePanel.ts
  • src/webview_provider/altimateWebviewProvider.ts
  • src/webview_provider/sqlLineagePanel.ts
  • src/webview_provider/queryResultPanel.ts
  • src/webview_provider/newDocsGenPanel.ts
  • src/webview_provider/docsEditPanel.ts
  • src/webview_provider/modelGraphViewPanel.ts
🔗 Analysis chain

Improved method naming for better clarity.

The renaming of resolveWebviewView to renderSqlVisualizer enhances code readability by more accurately describing the method's purpose. This change is a step in the right direction for maintaining clear and self-documenting code.

To ensure consistency across the codebase, let's verify if this method has been renamed in all relevant files:


Correction needed for file type specification in search scripts.

The initial shell scripts failed because rg does not recognize typescript as a valid file type. To resolve this, we'll use the correct file type identifier ts for TypeScript files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of 'resolveWebviewView' in TypeScript files
echo "Searching for 'resolveWebviewView':"
rg --type typescript 'resolveWebviewView'

# Search for occurrences of 'renderSqlVisualizer' to ensure consistent usage
echo "Searching for 'renderSqlVisualizer':"
rg --type typescript 'renderSqlVisualizer'

Length of output: 330


Script:

#!/bin/bash
# Search for any remaining instances of 'resolveWebviewView' in TypeScript files
echo "Searching for 'resolveWebviewView':"
rg --type ts 'resolveWebviewView'

# Search for occurrences of 'renderSqlVisualizer' to ensure consistent usage
echo "Searching for 'renderSqlVisualizer':"
rg --type ts 'renderSqlVisualizer'

Length of output: 1138

} catch (e) {
const errorMessage = (e as Error)?.message;
this.dbtTerminal.error("sqlLineage", errorMessage, e, true);
Expand Down
26 changes: 25 additions & 1 deletion src/webview_provider/altimateWebviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,17 @@ export class AltimateWebviewProvider implements WebviewViewProvider {
}
}

protected async checkIfWebviewReady() {
return new Promise<void>((resolve) => {
const interval = setInterval(() => {
if (this.isWebviewReady) {
clearInterval(interval);
resolve();
}
}, 500);
});
}
Comment on lines +526 to +535
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider optimizing the webview ready check

The checkIfWebviewReady method provides a way to asynchronously wait for the webview to be ready, which is good. However, there are a few potential improvements:

  1. Instead of using setInterval, consider using setTimeout with a recursive approach. This would be more efficient, especially if the webview takes a while to be ready.
  2. Add a timeout mechanism to prevent an infinite loop if isWebviewReady never becomes true.

Here's a suggested implementation:

protected async checkIfWebviewReady(timeout = 30000): Promise<void> {
  return new Promise<void>((resolve, reject) => {
    const startTime = Date.now();
    const check = () => {
      if (this.isWebviewReady) {
        resolve();
      } else if (Date.now() - startTime > timeout) {
        reject(new Error('Timeout waiting for webview to be ready'));
      } else {
        setTimeout(check, 500);
      }
    };
    check();
  });
}

This implementation will reject the promise if the webview isn't ready within the specified timeout (default 30 seconds).


resolveWebviewView(
panel: WebviewView,
context: WebviewViewResolveContext<unknown>,
Expand Down Expand Up @@ -587,6 +598,17 @@ export class AltimateWebviewProvider implements WebviewViewProvider {
),
),
);
const LineageGif = webview.asWebviewUri(
Uri.file(
path.join(
extensionUri.fsPath,
"webview_panels",
"dist",
"assets",
"lineage.gif",
),
),
);
const codiconsUri = webview.asWebviewUri(
Uri.joinPath(
extensionUri,
Expand Down Expand Up @@ -616,12 +638,14 @@ export class AltimateWebviewProvider implements WebviewViewProvider {
<link rel="stylesheet" type="text/css" href="${codiconsUri}">
</head>

<body>
<body class="${this.viewPath.replace(/\//g, "")}">
<div id="root"></div>
<div id="sidebar"></div>
<div id="modal"></div>
<script nonce="${nonce}" >
window.viewPath = "${this.viewPath}";
var spinnerUrl = "${SpinnerUrl}"
var lineageGif = "${LineageGif}"
</script>

<script nonce="${nonce}" type="module" src="${indexJs}"></script>
Expand Down
10 changes: 1 addition & 9 deletions src/webview_provider/lineagePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
const { command, args } = message;
// common commands
if (command === "openFile") {
const { url } = args;
const url = args.params?.url;
if (!url) {
return;
}
Expand Down Expand Up @@ -173,14 +173,6 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
return;
}

if (command === "openURL") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is handled via altimateWebviewProvider

if (!args.url) {
return;
}
env.openExternal(Uri.parse(args.url));
return;
}

if (command === "reactError") {
const typeMapper: { [key: string]: string } = {
generic: "Generic",
Expand Down
Loading