Skip to content

Routers

HTTP route handlers. The running API also serves the OpenAPI UI at /docs.

app.routers.admin

Reload the ontology from disk without restarting the API.

app.routers.entities

Entity routes: GeoJSON pins, facet counts, and per-entity triples.

app.routers.filters

Filter-panel route.

app.routers.stories

Stories proxy: count upstream stories for a set of concept IRIs.

_wp_tag_ids(iris, store)

Return the compass:wpTagId of each concept, skipping unmapped or invalid IRIs.

Parameters:

Name Type Description Default
iris list[str]

Concept IRIs from the tags query parameter.

required
store RDFStore

Live RDF store.

required

Returns:

Type Description
list[int]

Distinct term IDs found in the graph.

Source code in src/backend/app/routers/stories.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def _wp_tag_ids(iris: list[str], store: RDFStore) -> list[int]:
    """Return the ``compass:wpTagId`` of each concept, skipping unmapped or invalid IRIs.

    Args:
        iris: Concept IRIs from the ``tags`` query parameter.
        store: Live RDF store.

    Returns:
        Distinct term IDs found in the graph.
    """
    terms = [iri_term(iri) for iri in iris if is_iri(iri)]
    if not terms:
        return []
    values_clause = " ".join(terms)
    sparql = f"""
    PREFIX compass: <{COMPASS}>
    SELECT DISTINCT ?wpTagId WHERE {{
        VALUES ?concept {{ {values_clause} }}
        ?concept compass:wpTagId ?wpTagId .
    }}
    """
    return [int(row["wpTagId"]) for row in store.query(sparql)]