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