Skip to content

Commit

Permalink
[OPIK-409] [FE][Experiments page][Grouping and charts] Implement sort…
Browse files Browse the repository at this point in the history
…ing of groups by last created experiment (#750)
  • Loading branch information
andriidudar authored Nov 28, 2024
1 parent ec20404 commit 3aac1d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/opik-frontend/src/api/datasets/useDatasetsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -24,6 +27,7 @@ const getDatasetsList = async (
withExperimentsOnly,
promptId,
search,
sorting,
size,
page,
}: UseDatasetsListParams,
Expand All @@ -35,6 +39,7 @@ const getDatasetsList = async (
...(isBoolean(withExperimentsOnly) && {
with_experiments_only: withExperimentsOnly,
}),
...processSorting(sorting),
...(search && { name: search }),
...(promptId && { prompt_id: promptId }),
size,
Expand Down
3 changes: 3 additions & 0 deletions apps/opik-frontend/src/hooks/useGroupedExperimentsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,6 +123,7 @@ export default function useGroupedExperimentsList(
page: params.page,
size: params.size,
withExperimentsOnly: true,
sorting: GROUP_SORTING,
promptId: params.promptId,
},
{
Expand Down

0 comments on commit 3aac1d0

Please sign in to comment.