fix: make search work
This commit is contained in:
@@ -190,7 +190,7 @@ const Search = (
|
||||
onInput={handleInputChange}
|
||||
/>
|
||||
</div>
|
||||
<Checkbox label="unseen" checked={showSeenStatus} />
|
||||
<Checkbox label="unrated" checked={showSeenStatus} />
|
||||
<div
|
||||
class={showSeenStatus.value ? "opacity-10" : ""}
|
||||
>
|
||||
|
||||
@@ -74,7 +74,7 @@ export function getRecommendation(
|
||||
}
|
||||
|
||||
export async function getSimilarMovies(id: string) {
|
||||
const recs = getRecommendation(id, "movie");
|
||||
const recs = getRecommendation(id, "movies");
|
||||
if (!recs?.keywords?.length) return;
|
||||
|
||||
const recommendations = await openai.getMovieRecommendations(
|
||||
|
||||
@@ -60,7 +60,7 @@ export async function searchResource(
|
||||
(!types || types.includes("recipes")) && listResources("recipes"),
|
||||
])).flat().filter(isResource);
|
||||
|
||||
console.log({ types, rating, tags, q });
|
||||
console.log({ types, rating, tags, q, resourceLength: resources.length });
|
||||
|
||||
const results: Record<string, GenericResource> = {};
|
||||
|
||||
@@ -104,6 +104,7 @@ export async function searchResource(
|
||||
],
|
||||
threshold: 0.3,
|
||||
});
|
||||
console.log({ fuzzyResult });
|
||||
for (const result of fuzzyResult) {
|
||||
results[result.obj.name] = result.obj;
|
||||
}
|
||||
|
||||
2
routes/admin/cache/index.tsx
vendored
2
routes/admin/cache/index.tsx
vendored
@@ -20,7 +20,7 @@ export default function Greet(
|
||||
<MainLayout
|
||||
url={props.url}
|
||||
title="Recipes"
|
||||
context={{ type: "recipe" }}
|
||||
context={{ type: "recipes" }}
|
||||
>
|
||||
<code>
|
||||
<pre class="text-white">
|
||||
|
||||
@@ -19,9 +19,9 @@ const GET = async (
|
||||
throw new BadRequestError();
|
||||
}
|
||||
|
||||
const type = u.searchParams.get("type") || "movie";
|
||||
const type = u.searchParams.get("type") || "movies";
|
||||
|
||||
const res = type === "movie"
|
||||
const res = type === "movies"
|
||||
? await searchMovie(query)
|
||||
: await searchTVShow(query);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ export default function Greet(
|
||||
context={article}
|
||||
>
|
||||
<RedirectSearchHandler />
|
||||
<KMenu type="main" context={{ type: "article" }} />
|
||||
<KMenu type="main" context={{ type: "articles" }} />
|
||||
<MetaTags resource={article} />
|
||||
|
||||
<PageHero
|
||||
|
||||
@@ -17,7 +17,7 @@ export const handler: Handlers<
|
||||
const articles = await listResources<ArticleResource>("articles");
|
||||
const searchParams = parseResourceUrl(req.url);
|
||||
const searchResults = searchParams &&
|
||||
await searchResource({ ...searchParams, types: ["article"] });
|
||||
await searchResource({ ...searchParams, types: ["articles"] });
|
||||
return ctx.render({ articles, searchResults });
|
||||
},
|
||||
};
|
||||
@@ -32,7 +32,7 @@ export default function Greet(
|
||||
<MainLayout
|
||||
url={props.url}
|
||||
title="Articles"
|
||||
context={{ type: "article" }}
|
||||
context={{ type: "articles" }}
|
||||
searchResults={searchResults}
|
||||
>
|
||||
<header class="flex gap-4 items-center mb-5 md:hidden">
|
||||
@@ -47,7 +47,7 @@ export default function Greet(
|
||||
<h3 class="text-2xl text-white font-light">📝 Articles</h3>
|
||||
</header>
|
||||
<RedirectSearchHandler />
|
||||
<KMenu type="main" context={{ type: "article" }} />
|
||||
<KMenu type="main" context={{ type: "articles" }} />
|
||||
<Grid>
|
||||
{articles?.map((doc) => (
|
||||
<ResourceCard
|
||||
|
||||
@@ -72,7 +72,7 @@ export default async function Greet(
|
||||
{movie.name && (
|
||||
<Recommendations
|
||||
id={movie.name}
|
||||
type="movie"
|
||||
type="movies"
|
||||
/>
|
||||
)}
|
||||
<div class="px-8 text-white mt-10">
|
||||
|
||||
@@ -22,7 +22,7 @@ export default async function MovieIndex(
|
||||
const allMovies = await listResources<ReviewResource>("movies");
|
||||
const searchParams = parseResourceUrl(props.url);
|
||||
const searchResults = searchParams &&
|
||||
await searchResource({ ...searchParams, types: ["movie"] });
|
||||
await searchResource({ ...searchParams, types: ["movies"] });
|
||||
const movies = allMovies.sort((a, b) =>
|
||||
sortOptional(
|
||||
a.content.reviewRating?.ratingValue,
|
||||
@@ -34,11 +34,11 @@ export default async function MovieIndex(
|
||||
<MainLayout
|
||||
url={props.url}
|
||||
title="Movies"
|
||||
context={{ type: "movie" }}
|
||||
context={{ type: "movies" }}
|
||||
searchResults={searchResults}
|
||||
>
|
||||
<RedirectSearchHandler />
|
||||
<KMenu type="main" context={{ type: "movie" }} />
|
||||
<KMenu type="main" context={{ type: "movies" }} />
|
||||
<header class="flex gap-4 items-center mb-5 md:hidden">
|
||||
<a
|
||||
class="px-4 ml-4 py-2 bg-gray-300 text-gray-800 rounded-lg flex items-center gap-1"
|
||||
|
||||
@@ -16,7 +16,7 @@ export const handler: Handlers<
|
||||
const recipes = await listResources<RecipeResource>("recipes");
|
||||
const searchParams = parseResourceUrl(req.url);
|
||||
const searchResults = searchParams &&
|
||||
await searchResource({ ...searchParams, types: ["recipe"] });
|
||||
await searchResource({ ...searchParams, types: ["recipes"] });
|
||||
return ctx.render({ recipes, searchResults });
|
||||
},
|
||||
};
|
||||
@@ -32,10 +32,10 @@ export default function Greet(
|
||||
url={props.url}
|
||||
title="Recipes"
|
||||
searchResults={searchResults}
|
||||
context={{ type: "recipe" }}
|
||||
context={{ type: "recipes" }}
|
||||
>
|
||||
<RedirectSearchHandler />
|
||||
<KMenu type="main" context={{ type: "recipe" }} />
|
||||
<KMenu type="main" context={{ type: "recipes" }} />
|
||||
<header class="flex gap-4 items-center mb-2 lg:mb-5 md:hidden">
|
||||
<a
|
||||
class="px-4 lg:ml-4 py-2 bg-gray-300 text-gray-800 rounded-lg flex items-center gap-1"
|
||||
|
||||
Reference in New Issue
Block a user