diff --git a/apps/opik-frontend/src/api/datasets/useDatasetsList.ts b/apps/opik-frontend/src/api/datasets/useDatasetsList.ts index 962d5826e9..67bcff1950 100644 --- a/apps/opik-frontend/src/api/datasets/useDatasetsList.ts +++ b/apps/opik-frontend/src/api/datasets/useDatasetsList.ts @@ -2,12 +2,15 @@ import { QueryFunctionContext, useQuery } from "@tanstack/react-query"; import isBoolean from "lodash/isBoolean"; import api, { DATASETS_REST_ENDPOINT, QueryConfig } from "@/api/api"; import { Dataset } from "@/types/datasets"; +import { Sorting } from "@/types/sorting"; +import { processSorting } from "@/lib/sorting"; type UseDatasetsListParams = { workspaceName: string; withExperimentsOnly?: boolean; promptId?: string; search?: string; + sorting?: Sorting; page: number; size: number; }; @@ -24,6 +27,7 @@ const getDatasetsList = async ( withExperimentsOnly, promptId, search, + sorting, size, page, }: UseDatasetsListParams, @@ -35,6 +39,7 @@ const getDatasetsList = async ( ...(isBoolean(withExperimentsOnly) && { with_experiments_only: withExperimentsOnly, }), + ...processSorting(sorting), ...(search && { name: search }), ...(promptId && { prompt_id: promptId }), size, diff --git a/apps/opik-frontend/src/hooks/useGroupedExperimentsList.ts b/apps/opik-frontend/src/hooks/useGroupedExperimentsList.ts index 616bc8a4be..5bab1128d2 100644 --- a/apps/opik-frontend/src/hooks/useGroupedExperimentsList.ts +++ b/apps/opik-frontend/src/hooks/useGroupedExperimentsList.ts @@ -19,6 +19,8 @@ export const DEFAULT_GROUPS_PER_PAGE = 5; export const DEFAULT_EXPERIMENTS_PER_GROUP = 25; export const GROUPING_COLUMN = "virtual_dataset_id"; +export const GROUP_SORTING = [{ id: "last_created_experiment_at", desc: true }]; + export type GroupedExperiment = { dataset: Dataset; virtual_dataset_id: string; @@ -121,6 +123,7 @@ export default function useGroupedExperimentsList( page: params.page, size: params.size, withExperimentsOnly: true, + sorting: GROUP_SORTING, promptId: params.promptId, }, {