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

Fix timeseries #1167

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -15,22 +15,17 @@ const App: React.FC<Props> = (props) => {
const modelId = useAppSelector((state) => state.model.modelId);
const {
data: model,
isFetching: fetchingModel,
isSuccess: successModel,
} = useGetModelQuery(modelId);
const {
data: tableMetadata,
isFetching: fetchingTableMetadata,
isSuccess: successTableMetadata,
data: tableMetadata
} = useGetTableMetadataQuery(successModel ? model._id : skipToken);
const {
data: clusters,
isFetching: fetchingClusters,
isSuccess: successClusters,
data: clusters
} = useGetClustersQuery(successModel ? model._id : skipToken);

// Only continue if we fetched all the data we need
if (successModel && successTableMetadata && successClusters) {
if (successModel) {
return (
<TimeseriesComponents
model={model}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,34 @@ type Props = {
"artifact:jid": string;
"artifact:hostname": string;
};
clusters: [];
clusters: [] | undefined;
tableMetadata: {
"column-count": number;
};
} | undefined;
};

export default class TimeseriesComponents extends React.Component<Props> {
componentDidMount() {
if (this.props.model.state == "closed") {
/**
* determine if we should mount the loading page or the actually timeseries model
*
* @param props see Props type
* @returns JSX
*/
const TimeseriesComponents = (props: Props) => {
const { model, clusters, tableMetadata, dispatch, get_state, subscribe } = props;
if (model.state == "closed" && clusters && tableMetadata) {
initialize_timeseries_model(
this.props.dispatch,
this.props.get_state,
this.props.subscribe,
this.props.model,
this.props.clusters,
this.props.tableMetadata
dispatch,
get_state,
subscribe,
model,
clusters,
tableMetadata
);
}
}

render() {
const { model, clusters, tableMetadata, dispatch, get_state, subscribe } = this.props;

// Show loading page if model is not ready
// check if we are running or wating on the cluster
if (model["state"] === "waiting" || model["state"] === "running") {
// Show loading page
return (
<LoadingPage
modelId={model._id}
Expand All @@ -66,5 +69,6 @@ export default class TimeseriesComponents extends React.Component<Props> {
<Table modelId={model._id} />
</>
);
}
}

export default React.memo(TimeseriesComponents);