Skip to content
Snippets Groups Projects
Commit e6eb71de authored by schneider210's avatar schneider210
Browse files

fix: amount of total hits and distinctive sheets

parent f67356b7
No related branches found
No related tags found
1 merge request!50hits per sheet optimisation
Pipeline #220259 passed
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<p v-if="total > 0"> <p v-if="total > 0">
Found a total of <code class="font-weight-black">{{ total }}</code> Found a total of <code class="font-weight-black">{{ total }}</code>
{{ 'Hit' | numerus(total) }} for <code class="font-weight-black">{{ query }}</code> in {{ 'Hit' | numerus(total) }} for <code class="font-weight-black">{{ query }}</code> in
<!-- <code class="font-weight-black">{{ distinctSheets }}</code> {{ 'Sheet' | numerus(distinctSheets) }} and --> <code class="font-weight-black">{{ distinctSheets }}</code> {{ 'Sheet' | numerus(distinctSheets) }} and
<code class="font-weight-black">{{ distinctManuscripts }}</code> {{ 'Manuscript' | numerus(distinctManuscripts) }}. <code class="font-weight-black">{{ distinctManuscripts }}</code> {{ 'Manuscript' | numerus(distinctManuscripts) }}.
</p> </p>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
@click="scrollUp()" @click="scrollUp()"
> >
<v-pagination <v-pagination
v-if="total > size" v-if="distinctSheets > size"
v-model="page" v-model="page"
:length="pagesAmount" :length="pagesAmount"
:total-visible="7" :total-visible="7"
...@@ -55,6 +55,7 @@ export default { ...@@ -55,6 +55,7 @@ export default {
data() { data() {
return { return {
distinctManuscripts: 0, distinctManuscripts: 0,
distinctSheets: 0,
hitCounter: 0, hitCounter: 0,
items: [], items: [],
loading: false, loading: false,
...@@ -82,16 +83,12 @@ export default { ...@@ -82,16 +83,12 @@ export default {
}, },
}, },
computed: { computed: {
distinctSheets() {
const distinct = [...new Set(this.items.map(item => item.n))];
return distinct.length;
},
invalid() { invalid() {
return this.query.match(/^\s*$/); return this.query.match(/^\s*$/);
}, },
pagesAmount() { pagesAmount() {
return this.total > 0 return this.distinctSheets > 0
? Math.ceil(this.total / this.size) ? Math.ceil(this.distinctSheets / this.size)
: 1; : 1;
}, },
}, },
...@@ -115,6 +112,7 @@ export default { ...@@ -115,6 +112,7 @@ export default {
try { try {
this.items = []; this.items = [];
this.total = 0; this.total = 0;
this.distinctSheets = 0;
this.loading = true; this.loading = true;
...@@ -125,12 +123,15 @@ export default { ...@@ -125,12 +123,15 @@ export default {
this.items = items.map(x => ({ ...x, searchTerm: value })); this.items = items.map(x => ({ ...x, searchTerm: value }));
this.distinctManuscripts = searchResponse.hits?.total?.manifests || 0; this.distinctManuscripts = searchResponse.hits?.total?.manifests || 0;
this.total = searchResponse.hits?.total?.value || 0; this.distinctSheets = searchResponse.hits?.total?.value || 0;
this.total = searchResponse.hits?.total?.matches || 0;
} }
if (!this.invalid) this.message = `No search results found for <code>${this.query}</code>.`; if (!this.invalid) this.message = `No search results found for <code>${this.query}</code>.`;
} catch(error) { } catch(error) {
this.items = []; this.items = [];
this.distinctSheets = 0;
this.total = 0; this.total = 0;
this.message = 'Please enter a valid search term.'; this.message = 'Please enter a valid search term.';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment