fix(search): full-text indexes+caching

Adds a few new indexes to handle full-text searches instead of doing
`ILIKE` matching, improving performance substantially.
Alongside that, a few other things were done in order to improve search
performance, such as caching filter values so they're not computed on
each request to /api/roms. Overall, this should have a very noticeable
impact on large collections when using the search feature.
This commit is contained in:
Daniel Bonofiglio
2026-06-16 20:32:14 -03:00
parent 00af28821c
commit d5ffeeeddb
13 changed files with 504 additions and 67 deletions

View File

@@ -130,12 +130,17 @@ function updateSelectedRom(rom: SimpleRom) {
type SortBy = { key: keyof SimpleRom; order: "asc" | "desc" }[];
function updateOptions({ sortBy }: { sortBy: SortBy }) {
if (!sortBy[0]) return;
const { key, order } = sortBy[0];
romsStore.resetPagination();
romsStore.setOrderBy(key);
romsStore.setOrderDir(order);
if (sortBy[0]) {
const { key, order } = sortBy[0];
romsStore.setOrderBy(key);
romsStore.setOrderDir(order);
} else {
// Clear the `orderBy` key when the user removes
// the sort column from the table
romsStore.setOrderBy(null);
romsStore.setOrderDir("asc");
}
romsStore.fetchRoms();
}
</script>