Skip to content

Commit

Permalink
feat(CE): update model query types
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitd94 authored Dec 16, 2024
1 parent 6f6a63d commit 607f6eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ui/src/components/ModelTable/ModelTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import GenerateTable from '@/components/Table/Table';
import { getAllModels, GetAllModelsResponse } from '@/services/models';
import { AllDataModels, getAllModels, GetAllModelsResponse } from '@/services/models';
import { addIconDataToArray, ConvertToTableData } from '@/utils';
import NoModels from '@/views/Models/NoModels';
import Loader from '@/components/Loader';
Expand All @@ -16,7 +16,7 @@ const ModelTable = ({ handleOnRowClick }: ModelTableProps): JSX.Element => {

const { data } = useQueryWrapper<ApiResponse<GetAllModelsResponse[]>, Error>(
['models', activeWorkspaceId],
() => getAllModels({ type: 'data' }),
() => getAllModels({ type: AllDataModels }),
{
refetchOnMount: true,
refetchOnWindowFocus: false,
Expand Down
6 changes: 3 additions & 3 deletions ui/src/services/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export type GetAllModelsResponse = {
attributes: ModelAttributes;
};

export type ModelQueryType = 'data' | 'ai_ml' | 'raw_sql' | 'dbt' | 'soql' | 'table_selector';
export const AllDataModels = 'raw_sql,dbt,soql,table_selector';

export type GetAllModelsProps = {
type: ModelQueryType;
type: string;
};

export const getModelPreview = async (query: string, connector_id: string): Promise<any> => {
Expand All @@ -59,7 +59,7 @@ export const getModelPreview = async (query: string, connector_id: string): Prom
};

export const getAllModels = async ({
type = 'data',
type = AllDataModels,
}: GetAllModelsProps): Promise<ApiResponse<GetAllModelsResponse[]>> =>
multiwovenFetch<null, ApiResponse<GetAllModelsResponse[]>>({
method: 'get',
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/Models/ModelsList/ModelsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TopBar from '@/components/TopBar';
import { Box } from '@chakra-ui/react';
import { FiPlus } from 'react-icons/fi';
import { useQuery } from '@tanstack/react-query';
import { getAllModels, GetAllModelsResponse } from '@/services/models';
import { AllDataModels, getAllModels, GetAllModelsResponse } from '@/services/models';
import Loader from '@/components/Loader';
import NoModels from '@/views/Models/NoModels';
import { useStore } from '@/stores';
Expand All @@ -22,7 +22,7 @@ const ModelsList = (): JSX.Element | null => {

const { data, isLoading } = useQuery({
queryKey: ['models', activeWorkspaceId, 'data'],
queryFn: () => getAllModels({ type: 'data' }),
queryFn: () => getAllModels({ type: AllDataModels }),
refetchOnMount: true,
refetchOnWindowFocus: false,
enabled: activeWorkspaceId > 0,
Expand Down

0 comments on commit 607f6eb

Please sign in to comment.