From 788c178157c7115b389f0d50ddec221b6e92df37 Mon Sep 17 00:00:00 2001 From: Jeremy Asuncion Date: Wed, 6 Nov 2024 11:48:33 -0800 Subject: [PATCH] feat: order datasets by release date (#1320) Orders datasets on the `/browse-data/datasets` page by release date as the default sort --- .../app/graphql/getBrowseDatasets.server.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/packages/data-portal/app/graphql/getBrowseDatasets.server.ts b/frontend/packages/data-portal/app/graphql/getBrowseDatasets.server.ts index e23e36ff5..8c061c10f 100644 --- a/frontend/packages/data-portal/app/graphql/getBrowseDatasets.server.ts +++ b/frontend/packages/data-portal/app/graphql/getBrowseDatasets.server.ts @@ -12,13 +12,13 @@ const GET_DATASETS_DATA_QUERY = gql(` query GetDatasetsData( $limit: Int, $offset: Int, - $order_by_dataset: order_by, + $order_by: datasets_order_by!, $filter: datasets_bool_exp, ) { datasets( limit: $limit, offset: $offset, - order_by: { title: $order_by_dataset }, + order_by: [$order_by], where: $filter ) { id @@ -382,7 +382,13 @@ export async function getBrowseDatasets({ filter: getFilter(getFilterState(params), query), limit: MAX_PER_PAGE, offset: (page - 1) * MAX_PER_PAGE, - order_by_dataset: orderBy, + + // Order by dataset title if orderBy is set, otherwise order by release date + order_by: orderBy + ? { title: orderBy } + : { + release_date: Order_By.Desc, + }, }, })