From 9f97fd4fede9a94900fc2525d61e550e33079eb9 Mon Sep 17 00:00:00 2001 From: Robin Pyon Date: Mon, 17 Jul 2023 11:44:03 +0100 Subject: [PATCH] refactor(core): update consts to better match corresponding env vars --- .../@sanity/base/src/search/weighted/createSearchQuery.ts | 4 ++-- packages/@sanity/schema/src/legacy/searchConfig/resolve.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/@sanity/base/src/search/weighted/createSearchQuery.ts b/packages/@sanity/base/src/search/weighted/createSearchQuery.ts index 91e43c8e0a3..39a73d68031 100644 --- a/packages/@sanity/base/src/search/weighted/createSearchQuery.ts +++ b/packages/@sanity/base/src/search/weighted/createSearchQuery.ts @@ -37,7 +37,7 @@ interface IntermediateSearchType extends Omit { export const DEFAULT_LIMIT = 1000 // Maximum number of unique searchable attributes to include in a single search query (across all document types) -const MAX_UNIQUE_ATTRIBUTES = +const SEARCH_ATTR_LIMIT = // eslint-disable-next-line no-process-env Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_ATTR_LIMIT) || 1000 @@ -213,7 +213,7 @@ export function createSearchQuery( * These optimized specs are used when building constraints in this search query and assigning * weight to search hits. */ - const optimizedSpecs = createSearchSpecs(searchTerms.types, true, MAX_UNIQUE_ATTRIBUTES).specs + const optimizedSpecs = createSearchSpecs(searchTerms.types, true, SEARCH_ATTR_LIMIT).specs // Construct search filters used in this GROQ query const filters = [ diff --git a/packages/@sanity/schema/src/legacy/searchConfig/resolve.ts b/packages/@sanity/schema/src/legacy/searchConfig/resolve.ts index d82a1980ecd..cefff4a9d2c 100644 --- a/packages/@sanity/schema/src/legacy/searchConfig/resolve.ts +++ b/packages/@sanity/schema/src/legacy/searchConfig/resolve.ts @@ -21,11 +21,11 @@ export const pathCountSymbol = Symbol('__cachedPathCount') // Max number of levels to traverse per root-level object // eslint-disable-next-line no-process-env -const MAX_TRAVERSAL_DEPTH = Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_DEPTH) || 15 +const SEARCH_DEPTH_LIMIT = Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_DEPTH_LIMIT) || 15 // Max number of search paths to extract per root-level object // eslint-disable-next-line no-process-env -const MAX_OBJECT_SEARCH_PATHS = Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_PATH_LIMIT) || 500 +const SEARCH_PATH_LIMIT = Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_PATH_LIMIT) || 500 const BASE_WEIGHTS = [ {weight: 1, path: ['_id']}, @@ -187,5 +187,5 @@ export function resolveSearchConfigForBaseFieldPaths(type: ObjectSchemaType): Se } export default function resolveSearchConfig(type: ObjectSchemaType): SearchPath[] { - return getCachedStringFieldPaths(type, MAX_TRAVERSAL_DEPTH, MAX_OBJECT_SEARCH_PATHS) + return getCachedStringFieldPaths(type, SEARCH_DEPTH_LIMIT, SEARCH_PATH_LIMIT) }