Skip to content

Commit

Permalink
Get SOLR pagination info from params.json if available. (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
theorm authored Aug 2, 2024
1 parent 552a061 commit 474ad3b
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/logic/textReuse/solr.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,28 @@ function getClusterIdsAndTextFromPassagesSolrResponse(solrResponse) {
}

function getPaginationInfoFromPassagesSolrResponse(solrResponse) {
return {
limit: parseInt(get(solrResponse, 'responseHeader.params.rows', '10'), 10),
offset: parseInt(get(solrResponse, 'responseHeader.params.start', '0'), 10),
total: get(solrResponse, 'response.numFound'),
if (typeof get(solrResponse, 'responseHeader.params.json') === 'string') {
try {
const { params } = JSON.parse(solrResponse.responseHeader.params.json)
return {
limit: typeof params.rows === 'number' ? params.rows : 10,
offset: typeof params.start === 'number' ? params.start : 0,
total: get(solrResponse, 'response.numFound'),
}
} catch (e) {
console.warn(e)
return {
limit: 10,
offset: 0,
total: get(solrResponse, 'response.numFound'),
}
}
} else {
return {
limit: parseInt(get(solrResponse, 'responseHeader.params.rows', '10'), 10),
offset: parseInt(get(solrResponse, 'responseHeader.params.start', '0'), 10),
total: get(solrResponse, 'response.numFound'),
}
}
}

Expand Down

0 comments on commit 474ad3b

Please sign in to comment.