Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nos Hs2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Språksamlingane
stadnamn
Nos Hs2023
Commits
e9a6017c
Commit
e9a6017c
authored
4 years ago
by
esikkala
Browse files
Options
Downloads
Patches
Plain Diff
Literal facet: fix selected values
parent
0795b9aa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/server/sparql/FacetValues.js
+15
-8
15 additions, 8 deletions
src/server/sparql/FacetValues.js
with
15 additions
and
8 deletions
src/server/sparql/FacetValues.js
+
15
−
8
View file @
e9a6017c
...
@@ -93,7 +93,7 @@ export const getFacet = async ({
...
@@ -93,7 +93,7 @@ export const getFacet = async ({
/* if this facet has previous selections (exluding <http://ldf.fi/MISSING_VALUE>),
/* if this facet has previous selections (exluding <http://ldf.fi/MISSING_VALUE>),
they need to be binded as selected */
they need to be binded as selected */
if
(
currentSelectionsWithoutUnknown
.
length
>
0
&&
hasPreviousSelections
)
{
if
(
currentSelectionsWithoutUnknown
.
length
>
0
&&
hasPreviousSelections
)
{
selectedBlock
=
generateSelectedBlock
({
currentSelectionsWithoutUnknown
})
selectedBlock
=
generateSelectedBlock
({
currentSelectionsWithoutUnknown
,
literal
:
facetConfig
.
literal
})
}
}
/* if there is previous selections in this facet AND in some other facet, we need an
/* if there is previous selections in this facet AND in some other facet, we need an
additional block for facet values that return 0 hits */
additional block for facet values that return 0 hits */
...
@@ -104,7 +104,8 @@ export const getFacet = async ({
...
@@ -104,7 +104,8 @@ export const getFacet = async ({
facetID
,
facetID
,
constraints
,
constraints
,
// no defaultConstraint here
// no defaultConstraint here
currentSelectionsWithoutUnknown
currentSelectionsWithoutUnknown
,
literal
:
facetConfig
.
literal
})
})
}
}
}
}
...
@@ -181,11 +182,13 @@ export const getFacet = async ({
...
@@ -181,11 +182,13 @@ export const getFacet = async ({
}
}
const
generateSelectedBlock
=
({
const
generateSelectedBlock
=
({
currentSelectionsWithoutUnknown
currentSelectionsWithoutUnknown
,
literal
})
=>
{
})
=>
{
const
selectedFilter
=
generateSelectedFilter
({
const
selectedFilter
=
generateSelectedFilter
({
currentSelectionsWithoutUnknown
,
currentSelectionsWithoutUnknown
,
inverse
:
false
inverse
:
false
,
literal
})
})
return
`
return
`
OPTIONAL {
OPTIONAL {
...
@@ -200,7 +203,8 @@ const generateSelectedNoHitsBlock = ({
...
@@ -200,7 +203,8 @@ const generateSelectedNoHitsBlock = ({
facetClass
,
facetClass
,
facetID
,
facetID
,
constraints
,
constraints
,
currentSelectionsWithoutUnknown
currentSelectionsWithoutUnknown
,
literal
})
=>
{
})
=>
{
const
noHitsFilter
=
generateConstraintsBlock
({
const
noHitsFilter
=
generateConstraintsBlock
({
backendSearchConfig
,
backendSearchConfig
,
...
@@ -210,11 +214,12 @@ const generateSelectedNoHitsBlock = ({
...
@@ -210,11 +214,12 @@ const generateSelectedNoHitsBlock = ({
facetID
:
facetID
,
facetID
:
facetID
,
inverse
:
true
inverse
:
true
})
})
const
selections
=
literal
?
`'
${
currentSelectionsWithoutUnknown
.
join
(
'
,
'
)}
'`
:
`<
${
currentSelectionsWithoutUnknown
.
join
(
'
>, <
'
)}
>`
return
`
return
`
UNION
UNION
# facet values that have been selected but return no results
# facet values that have been selected but return no results
{
{
VALUES ?id {
<
${
currentS
elections
WithoutUnknown
.
join
(
'
> <
'
)}
>
}
VALUES ?id {
${
s
elections
}
}
${
noHitsFilter
}
${
noHitsFilter
}
BIND(true AS ?selected_)
BIND(true AS ?selected_)
}
}
...
@@ -299,9 +304,11 @@ const getUriFilters = (constraints, facetID) => {
...
@@ -299,9 +304,11 @@ const getUriFilters = (constraints, facetID) => {
export
const
generateSelectedFilter
=
({
export
const
generateSelectedFilter
=
({
currentSelectionsWithoutUnknown
,
currentSelectionsWithoutUnknown
,
inverse
inverse
,
literal
})
=>
{
})
=>
{
const
selections
=
literal
?
`'
${
currentSelectionsWithoutUnknown
.
join
(
'
,
'
)}
'`
:
`<
${
currentSelectionsWithoutUnknown
.
join
(
'
>, <
'
)}
>`
return
(
`
return
(
`
FILTER(?id
${
inverse
?
'
NOT
'
:
''
}
IN (
<
${
currentS
elections
WithoutUnknown
.
join
(
'
>, <
'
)}
>
))
FILTER(?id
${
inverse
?
'
NOT
'
:
''
}
IN (
${
s
elections
}
))
`
)
`
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment