Skip to content
Snippets Groups Projects
Commit d55bda6d authored by esikkala's avatar esikkala
Browse files

Add 'orderByPattern' to backend config

parent 5fdcd784
No related branches found
No related tags found
No related merge requests found
...@@ -183,16 +183,19 @@ const getPaginatedData = ({ ...@@ -183,16 +183,19 @@ const getPaginatedData = ({
sortByPredicate = sortDirection === 'asc' sortByPredicate = sortDirection === 'asc'
? config.facets[sortBy].sortByAscPredicate ? config.facets[sortBy].sortByAscPredicate
: config.facets[sortBy].sortByDescPredicate : config.facets[sortBy].sortByDescPredicate
} else if (has(config.facets[sortBy], 'orderByPattern')) {
q = q.replace('<ORDER_BY_TRIPLE>', config.facets[sortBy].orderByPattern)
} else { } else {
sortByPredicate = config.facets[sortBy].labelPath sortByPredicate = config.facets[sortBy].labelPath
} q = q.replace('<ORDER_BY_TRIPLE>',
q = q.replace('<ORDER_BY_TRIPLE>',
`OPTIONAL { ?id ${sortByPredicate} ?orderBy }`) `OPTIONAL { ?id ${sortByPredicate} ?orderBy }`)
}
q = q.replace('<ORDER_BY>', q = q.replace('<ORDER_BY>',
`ORDER BY (!BOUND(?orderBy)) ${sortDirection}(?orderBy)`) `ORDER BY (!BOUND(?orderBy)) ${sortDirection}(?orderBy)`)
} }
q = q.replace('<PAGE>', `LIMIT ${pagesize} OFFSET ${page * pagesize}`) q = q.replace('<PAGE>', `LIMIT ${pagesize} OFFSET ${page * pagesize}`)
q = q.replace('<RESULT_SET_PROPERTIES>', config.paginatedResults.properties) q = q.replace('<RESULT_SET_PROPERTIES>', config.paginatedResults.properties)
console.log(endpoint.prefixes + q)
return runSelectQuery({ return runSelectQuery({
query: endpoint.prefixes + q, query: endpoint.prefixes + q,
endpoint: endpoint.url, endpoint: endpoint.url,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment