Skip to content

Routers

HTTP route handlers. OpenAPI summaries and request/response shapes also appear in the running API's UI at /docs.

app.routers.admin

Reload the ontology from disk without restarting the API.

Editorial updates land as new Turtle files; this endpoint makes the running API pick them up. A rejected reload leaves the previous version serving. HTTP route descriptions live in OpenAPI (summary / description on the route decorators).

app.routers.entities

app.routers.filters

app.routers.stories

Stories proxy router.

Maps concept IRIs to upstream term IDs via compass:wpTagId, then queries the configured stories provider for a count. HTTP route descriptions live in OpenAPI (summary / description on the route decorators).

_resolve_tags_ids(iris, store)

Return upstream term IDs for the given concept IRIs.

Concepts without a compass:wpTagId mapping are skipped. Invalid IRIs are ignored.

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def _resolve_tags_ids(iris: list[str], store: RDFStore) -> list[int]:
    """Return upstream term IDs for the given concept IRIs.

    Concepts without a ``compass:wpTagId`` mapping are skipped. Invalid IRIs
    are ignored.

    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 .
    }}
    """
    rows = store.query(sparql)
    return [int(row["wpTagId"]) for row in rows if row.get("wpTagId")]