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

chore(weave): Add back hook to check for weave data #2774

Merged
merged 5 commits into from
Oct 24, 2024
Merged
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import React, {createContext, FC, useContext} from 'react';

import {useHasTraceServerClientContext} from './traceServerClientContext';
import {tsWFDataModelHooks} from './tsDataModelHooks';
import {WFDataModelHooksInterface} from './wfDataModelHooksInterface';

Expand All @@ -35,3 +36,44 @@ export const WFDataModelAutoProvider: FC<{
</WFDataModelHooksContext.Provider>
);
};

/**
* Returns true if the client can connect to trace server and the project has
* objects or calls.
*/
export const useProjectHasTraceServerData = (
entity: string,
project: string
) => {
const hasTraceServer = useHasTraceServerClientContext();
const objs = tsWFDataModelHooks.useRootObjectVersions(
entity,
project,
{},
1,
true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added metadata_only param

{
skip: !hasTraceServer,
}
);

const calls = tsWFDataModelHooks.useCalls(
Copy link
Collaborator

Choose a reason for hiding this comment

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

you could optimize this by selecting only the id column for example as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

entity,
project,
{},
1,
undefined,
undefined,
undefined,
undefined,
undefined,
{
skip: !hasTraceServer,
}
);
const loading = objs.loading || calls.loading;
return {
loading,
result: (objs.result ?? []).length > 0 || (calls.result ?? []).length > 0,
};
};
Loading