Skip to content

Commit 606d290

Browse files
author
John Rogers
committed
Remove all optional parameters from fetchResultByUuid lookup endpoint - only pass uuid or slug to improve API performance
1 parent 8e985ab commit 606d290

3 files changed

Lines changed: 5 additions & 60 deletions

File tree

src/app/discover/page.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,7 @@ function DiscoverPageContent() {
375375
try {
376376
setLoading(true);
377377
const studyResult = await fetchResultByUuid(
378-
searchSettings.similarUid,
379-
undefined,
380-
undefined,
381-
searchSettings.maxDistance,
382-
searchSettings.maxDistanceMode
378+
searchSettings.similarUid
383379
);
384380
setSimilarStudy(studyResult);
385381

src/components/StudyDetail.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,7 @@ const StudyDetailComponent = ({
389389

390390
const fetchData = async () => {
391391
try {
392-
const enhancedData = await fetchResultByUuid(
393-
currentUuid,
394-
debouncedQuery,
395-
debouncedHybridWeight,
396-
debouncedMaxDistance,
397-
debouncedMaxDistanceMode
398-
);
392+
const enhancedData = await fetchResultByUuid(currentUuid);
399393

400394
if (!cancelled) {
401395
setEnhancedStudy(enhancedData);

src/services/api.ts

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,7 @@ export async function fetchResultsByUuids(
632632
}
633633

634634
export async function fetchResultByUuid(
635-
identifier: string,
636-
query?: string,
637-
alpha?: number,
638-
maxVectorDistance?: number,
639-
maxDistanceMode: "max_distance" | "min_score" | "both" = "min_score"
635+
identifier: string
640636
): Promise<SearchResult> {
641637
console.log(`🔗 API CALL: fetchResultByUuid(${identifier})`);
642638
const params = new URLSearchParams();
@@ -653,26 +649,7 @@ export async function fetchResultByUuid(
653649
params.set("slug", identifier);
654650
}
655651

656-
// Append query parameter if provided
657-
if (query && query.trim()) {
658-
params.set("query", query.trim());
659-
}
660-
661-
// Append alpha parameter if provided
662-
if (alpha !== undefined) {
663-
params.set("alpha", alpha.toString());
664-
}
665-
666-
// Add max_vector_distance and/or min_original_vector_score based on mode
667-
// Always send these parameters (use default 0.4 if not provided)
668-
const distanceValue = maxVectorDistance !== undefined ? maxVectorDistance : 0.4;
669-
if (maxDistanceMode === "max_distance" || maxDistanceMode === "both") {
670-
params.set("max_vector_distance", distanceValue.toString());
671-
}
672-
if (maxDistanceMode === "min_score" || maxDistanceMode === "both") {
673-
params.set("min_original_vector_score", (1 - distanceValue).toString());
674-
}
675-
652+
// Only pass uuid or slug - no other parameters
676653
const url = `${API_BASE}/discover/lookup?${params.toString()}`;
677654
const response = await fetch(url);
678655

@@ -683,29 +660,7 @@ export async function fetchResultByUuid(
683660
const slugParams = new URLSearchParams();
684661
slugParams.set("slug", identifier);
685662

686-
// Append query parameter if provided
687-
if (query && query.trim()) {
688-
slugParams.set("query", query.trim());
689-
}
690-
691-
// Append alpha parameter if provided
692-
if (alpha !== undefined) {
693-
slugParams.set("alpha", alpha.toString());
694-
}
695-
696-
// Add max_vector_distance and/or min_original_vector_score based on mode
697-
// Always send these parameters (use default 0.4 if not provided)
698-
const distanceValue = maxVectorDistance !== undefined ? maxVectorDistance : 0.4;
699-
if (maxDistanceMode === "max_distance" || maxDistanceMode === "both") {
700-
slugParams.set("max_vector_distance", distanceValue.toString());
701-
}
702-
if (maxDistanceMode === "min_score" || maxDistanceMode === "both") {
703-
slugParams.set(
704-
"min_original_vector_score",
705-
(1 - distanceValue).toString()
706-
);
707-
}
708-
663+
// Only pass slug - no other parameters
709664
const slugUrl = `${API_BASE}/discover/lookup?${slugParams.toString()}`;
710665
const slugResponse = await fetch(slugUrl);
711666

0 commit comments

Comments
 (0)