From a828fee476221b550a5954507a503b2c239e8211 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Sat, 29 Feb 2020 03:22:51 +0100 Subject: [PATCH] Handling NULL actors and tags in search table query. Added limit parameter to home URL, default to 30. --- assets/components/home/home.vue | 5 ++++- src/releases.js | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/assets/components/home/home.vue b/assets/components/home/home.vue index f3eec400..fc409e1c 100644 --- a/assets/components/home/home.vue +++ b/assets/components/home/home.vue @@ -13,7 +13,10 @@ import FilterBar from '../header/filter-bar.vue'; import Releases from '../releases/releases.vue'; async function fetchReleases() { - this.releases = await this.$store.dispatch('fetchReleases', { limit: 50 }); + this.releases = await this.$store.dispatch('fetchReleases', { + limit: (this.$route.query && this.$route.query.limit && Number(this.$route.query.limit)) || 30, + }); + this.$store.commit('setCache', { target: 'home', releases: this.releases, diff --git a/src/releases.js b/src/releases.js index 614439d9..b0ae915c 100644 --- a/src/releases.js +++ b/src/releases.js @@ -378,8 +378,8 @@ async function updateReleasesSearch(releaseIds) { sites.name || ' ' || sites.slug || ' ' || replace(CAST(releases.date AS VARCHAR), '-', ' ') || ' ' || - string_agg(actors.name, ' ') || ' ' || - string_agg(tags.name, ' ') + string_agg(coalesce(actors.name, ''), ' ') || ' ' || + string_agg(coalesce(tags.name, ''), ' ') ) as document FROM releases JOIN sites ON releases.site_id = sites.id @@ -391,7 +391,7 @@ async function updateReleasesSearch(releaseIds) { GROUP BY releases.id, sites.name, sites.slug; `, [releaseIds]); - if (documents.row?.length > 0) { + if (documents.rows?.length > 0) { const query = knex('releases_search').insert(documents.rows).toString(); await knex.raw(`${query} ON CONFLICT (release_id) DO UPDATE SET document = EXCLUDED.document`); }