From 4e2962db29e9c32ea505e9b2d12864f697035074 Mon Sep 17 00:00:00 2001 From: Danny Miller Date: Fri, 31 May 2024 09:04:21 -0400 Subject: [PATCH] cleanup --- pages/[subdomain]/collection/[username]/[slugName].tsx | 2 +- pages/api/search/index.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/[subdomain]/collection/[username]/[slugName].tsx b/pages/[subdomain]/collection/[username]/[slugName].tsx index afea7820e..7acd4ff97 100644 --- a/pages/[subdomain]/collection/[username]/[slugName].tsx +++ b/pages/[subdomain]/collection/[username]/[slugName].tsx @@ -95,7 +95,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { search: search ? search.toString() : '', statFilter: statFilter ? statFilter.toString() as StatFilter : StatFilter.All, timeRange: TimeRange[TimeRange.All], - sortBy: 'sortField', + sortBy: 'collectionOrder', sortDir: 'asc', // TODO: when filtering, the original collection order is not maintained and instead we sort here // maybe need a separate doCollectionQuery function diff --git a/pages/api/search/index.ts b/pages/api/search/index.ts index 8e53f7f85..df1533b62 100644 --- a/pages/api/search/index.ts +++ b/pages/api/search/index.ts @@ -226,8 +226,8 @@ export async function doQuery(gameId: GameId, query: SearchQuery, reqUser?: User lookupUserBeforeSort = true; } else if (query.sortBy === 'name') { sortObj.push(['name', sortDirection]); - } else if (query.sortBy === 'sortField') { - sortObj.push(['sortField', sortDirection]); + } else if (query.sortBy === 'collectionOrder') { + sortObj.push(['collectionOrder', sortDirection]); } else if (query.sortBy === 'leastMoves') { sortObj.push(['leastMoves', sortDirection]); } else if (query.sortBy === 'ts') { @@ -433,7 +433,7 @@ export async function doQuery(gameId: GameId, query: SearchQuery, reqUser?: User { $project: { ...projection } }, { $addFields: { - sortField: { + collectionOrder: { $indexOfArray: [query.includeLevelIds?.split(','), { $toString: '$_id' }], } }