visualize-admin / visualization-tool

The tool for visualizing Swiss Open Government Data. Project ownership: Federal Office for the Environment FOEN
https://visualize.admin.ch
BSD 3-Clause "New" or "Revised" License
29 stars 3 forks source link

Termset search filter #1489

Closed ptbrowne closed 2 months ago

ptbrowne commented 2 months ago

Adds a section in the search page to filter cubes per termsets.

image
PREFIX cube: <https://cube.link/>
  PREFIX meta: <https://cube.link/meta/>
  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  PREFIX schema: <http://schema.org/>
  PREFIX sh: <http://www.w3.org/ns/shacl#>

  SELECT DISTINCT (COUNT(distinct ?iri) as ?count) ?termsetIri ?termsetLabel WHERE {
      ?iri cube:observationConstraint/sh:property ?dimension .
      ?dimension a cube:KeyDimension .
      ?dimension sh:in/rdf:rest*/rdf:first ?value.
      ?value schema:inDefinedTermSet ?termsetIri .
      ?termsetIri a meta:SharedDimension .
      OPTIONAL { ?termsetIri schema:name ?termsetLabel_en . FILTER(LANG(?termsetLabel_en) = "en") }
OPTIONAL { ?termsetIri schema:name ?termsetLabel_de . FILTER(LANG(?termsetLabel_de) = "de") }
OPTIONAL { ?termsetIri schema:name ?termsetLabel_fr . FILTER(LANG(?termsetLabel_fr) = "fr") }
OPTIONAL { ?termsetIri schema:name ?termsetLabel_it . FILTER(LANG(?termsetLabel_it) = "it") }
OPTIONAL { ?termsetIri schema:name ?termsetLabel_ . FILTER(LANG(?termsetLabel_) = "") }
BIND(COALESCE(?termsetLabel_en, ?termsetLabel_de, ?termsetLabel_fr, ?termsetLabel_it, ?termsetLabel_) AS ?termsetLabel)

    ?iri schema:workExample <https://ld.admin.ch/application/visualize> .
    ?iri schema:creativeWorkStatus <https://ld.admin.ch/vocabulary/CreativeWorkStatus/Published> .
    ?iri cube:observationConstraint ?shape .
    FILTER NOT EXISTS { ?iri schema:expires ?expiryDate }

    }      GROUP BY ?termsetIri ?termsetLabel
vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ā†—ļøŽ

Name Status Preview Comments Updated (UTC)
visualization-tool āœ… Ready (Inspect) Visit Preview šŸ’¬ Add feedback May 2, 2024 2:02pm
bprusinowski commented 2 months ago

@ptbrowne I think counts are correct, but there's rather a problem with cubes filtering šŸ¤”

bprusinowski commented 2 months ago

I think it might be related to

https://github.com/visualize-admin/visualization-tool/blob/77d23a0c71b1b70a8f4617af6870b18a61444044/app/rdf/query-search.ts#L234

vs

https://github.com/visualize-admin/visualization-tool/blob/77d23a0c71b1b70a8f4617af6870b18a61444044/app/rdf/query-termsets.ts#L26

? Not 100% sure, but just something I noticed :)

ptbrowne commented 2 months ago

Ah thanks for noticing, then counts are okay, we'll just have to revisit the query when the shared dimensions are materialised. See this issue.