Skip to content

Commit

Permalink
merged and fixed conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
DonKoko committed Oct 16, 2024
2 parents 851ef1a + c1246a6 commit 9994b36
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
24 changes: 19 additions & 5 deletions app/components/list/filters/clear-search.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import type { ButtonProps } from "~/components/shared/button";
import { Button } from "~/components/shared/button";
import { useSearchParams } from "~/hooks/search-params";

export const ClearSearch = ({
buttonProps,
children,
}: {
buttonProps?: ButtonProps;
children?: string;
}) => (
<Button to="." {...buttonProps}>
{children}
</Button>
);
}) => {
const [, setSearchParams] = useSearchParams();
return (
<Button
to="."
{...buttonProps}
onClick={() => {
setSearchParams((prev) => {
prev.delete("s");

return prev;
});
}}
>
{children}
</Button>
);
};
2 changes: 1 addition & 1 deletion app/components/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const List = React.forwardRef<HTMLDivElement, ListProps>(function List(
const { items, totalItems, perPage, modelName } =
useLoaderData<IndexResponse>();
const { singular, plural } = modelName;
const totalIncomingItems = items.length;
const totalIncomingItems = items?.length;
const hasItems = totalIncomingItems > 0;
const selectedBulkItemsCount = useAtomValue(selectedBulkItemsCountAtom);
const setSelectedBulkItems = useSetAtom(setSelectedBulkItemsAtom);
Expand Down
10 changes: 8 additions & 2 deletions app/modules/asset/advanced-index-query.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ export function generateWhereClause(
if (search) {
const words = search.trim().split(/\s+/).filter(Boolean);
if (words.length > 0) {
const searchVector = words.join(" & ");
whereClause = Prisma.sql`${whereClause} AND (to_tsvector('english', a.title) @@ to_tsquery('english', ${searchVector}))`;
const searchQuery = words
.map((word) => `${word}:* | ${word}`)
.join(" | ");
whereClause = Prisma.sql`
${whereClause} AND (
to_tsvector('english', a."title" || ' ' || COALESCE(a."description", '')) @@ to_tsquery('english', ${searchQuery})
)
`;
}
}

Expand Down
4 changes: 0 additions & 4 deletions app/modules/asset/service.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,6 @@ export async function getAdvancedPaginatedAndFilterableAssets({
${assetReturnFragment}
FROM sorted_asset_query aq;
`;

console.log(query.sql);
console.log(query.values);

const result = await db.$queryRaw<AdvancedIndexQueryResult>(query);
const totalAssets = result[0].total_count;
const assets: AdvancedIndexAsset[] = result[0].assets;
Expand Down

0 comments on commit 9994b36

Please sign in to comment.