Redesign the web app from a written design concept
Design concept and design system in docs/design/: principles (evidence
first, neutral, fair to the people shown, plain language, time as a
dimension, accessible and private), information architecture, core
patterns and a concept for every page; tokens with checked contrast,
component catalogue, content and accessibility rules.
web:
- neutral ink-indigo accent instead of flag red; party colours only as
small markers next to the name; light/dark theme with a switcher
- stylesheets split into tokens, base, layout, components, print
- new header (search, filter count, language, theme, mobile menu) and
footer; breadcrumbs, page headers, tabs with counts, filter bars that
collapse on phones, pagination, notices and empty states
- claim cards with source meter, legal stage, innocence notice inside
the card and a permalink; claim pages with citation (/angaben/{id})
- profiles with role timeline and key figures; party and organisation
dashboards; vote list with position chips; calendar agenda on phones;
tables that stack into cards; loading and error pages; favicon
backend:
- GET /api/v1/claims/{id} and MCP tool get_claim for permalinks
- parties list: evaluate person_status once instead of per party
(30 s -> 1 s on the sample database, identical result)
- parliament calendar: HTML-decode titles ("84. Sitzung")
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
45514624f4
commit
456f9816f4
76 files changed
+7127
-1280
No files matched your search
@@ -165,6 +165,13 @@ def get_claims(
|
||||
limit=limit, offset=offset)
|
||||
|
||||
|
||||
@app.get("/api/v1/claims/{claim_id}", response_model=s.Claim)
|
||||
def get_claim(claim_id: int, conn: DB, sources: Sources):
|
||||
"""One claim with all its evidence - the target of permalinks (callers normally omit the source filter)."""
|
||||
rows = queries.list_claims(conn, sources=sources, claim_id=claim_id, limit=1)
|
||||
return not_found(rows[0] if rows else None, "claim")
|
||||
|
||||
|
||||
@app.get("/api/v1/timeline", response_model=list[s.TimelineBucket])
|
||||
def get_timeline(conn: DB, sources: Sources, person: str | None = None, party: str | None = None):
|
||||
return queries.timeline_histogram(conn, sources=sources, person=person, party=party)
|
||||
|
||||
@@ -124,6 +124,14 @@ def list_claims(
|
||||
until=_date(until), limit=limit))
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def get_claim(claim_id: int) -> str:
|
||||
"""One claim with all its evidence, e.g. from a permalink (/angaben/<id>) a user shared."""
|
||||
with connection() as conn:
|
||||
rows = queries.list_claims(conn, sources=SourceFilter([], 0), claim_id=claim_id, limit=1)
|
||||
return _dump(rows[0] if rows else {"error": f"claim {claim_id} not found"})
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def money_flows(kinds: list[str] | None = None, organization: str | None = None, person: str | None = None,
|
||||
query: str | None = None, since: str | None = None, until: str | None = None,
|
||||
|
||||
@@ -21,6 +21,7 @@ def list_claims(
|
||||
since: date | None = None,
|
||||
until: date | None = None,
|
||||
q: str | None = None,
|
||||
claim_id: int | None = None,
|
||||
include_pending: bool = False,
|
||||
limit: int = 50,
|
||||
offset: int = 0,
|
||||
@@ -28,7 +29,7 @@ def list_claims(
|
||||
source_sql, params = sources.sql("s")
|
||||
params.update({
|
||||
"person": person, "party": party, "organization": organization, "claim_types": claim_types, "topics": topics, "since": since,
|
||||
"until": until, "q": q, "limit": limit, "offset": offset, "include_pending": include_pending,
|
||||
"until": until, "q": q, "claim_id": claim_id, "limit": limit, "offset": offset, "include_pending": include_pending,
|
||||
})
|
||||
return conn.execute(
|
||||
f"""
|
||||
@@ -73,6 +74,7 @@ def list_claims(
|
||||
AND (%(since)s::date IS NULL OR COALESCE(c.occurred_at::date, c.valid_to, c.valid_from, current_date) >= %(since)s)
|
||||
AND (%(until)s::date IS NULL OR COALESCE(c.occurred_at::date, c.valid_from) <= %(until)s)
|
||||
AND (%(q)s::text IS NULL OR c.summary_de ILIKE '%%' || %(q)s || '%%')
|
||||
AND (%(claim_id)s::bigint IS NULL OR c.id = %(claim_id)s)
|
||||
ORDER BY COALESCE(c.occurred_at, c.valid_from::timestamptz, c.created_at) DESC, c.id DESC
|
||||
LIMIT %(limit)s OFFSET %(offset)s
|
||||
""",
|
||||
|
||||
@@ -8,13 +8,21 @@ from psycopg import Connection
|
||||
def list_parties(conn: Connection) -> list[dict]:
|
||||
return conn.execute(
|
||||
"""
|
||||
-- person_status is an expensive view: evaluate it once, not once per party
|
||||
WITH active AS (
|
||||
SELECT party_id, count(DISTINCT ps.person_id) AS n
|
||||
FROM person_status ps, unnest(ps.current_party_ids) AS party_id
|
||||
WHERE ps.status = 'active'
|
||||
GROUP BY party_id
|
||||
)
|
||||
SELECT o.slug, o.name, o.short_name, o.color, o.logo_url,
|
||||
(SELECT count(*) FROM person_status ps WHERE ps.status = 'active' AND o.id = ANY(ps.current_party_ids))
|
||||
AS active_officials,
|
||||
COALESCE(a.n, 0) AS active_officials,
|
||||
count(DISTINCT r.person_id) AS total_people
|
||||
FROM organization o LEFT JOIN role r ON r.party_id = o.id
|
||||
FROM organization o
|
||||
LEFT JOIN role r ON r.party_id = o.id
|
||||
LEFT JOIN active a ON a.party_id = o.id
|
||||
WHERE o.kind = 'party'
|
||||
GROUP BY o.id
|
||||
GROUP BY o.id, a.n
|
||||
ORDER BY active_officials DESC, total_people DESC, o.name
|
||||
"""
|
||||
).fetchall()
|
||||
|
||||
@@ -99,6 +99,7 @@ class ParlamentCalendar(Adapter):
|
||||
name = "parlament.calendar"
|
||||
description = "Parliament calendar: plenary sessions, committees, hearings, events (tours skipped)"
|
||||
schedule = "30 2 * * *"
|
||||
parser_version = 2 # 2: titles are HTML-decoded ("84. Sitzung")
|
||||
|
||||
def start(self, ctx: RunContext) -> Iterator[Request]:
|
||||
yield list_request(600, {}, kind="list")
|
||||
@@ -106,12 +107,12 @@ class ParlamentCalendar(Adapter):
|
||||
def parse(self, ctx: RunContext, response: Response) -> Iterator[Event]:
|
||||
since = str(ctx.params.get("since_year", date.today().year - 2))
|
||||
for row in list_rows(response.json()):
|
||||
kind_label = (row.get("Terminart") or "").replace("<BR>", " ")
|
||||
kind_label = html_to_text(row.get("Terminart"))
|
||||
starts = next((v for k, v in row.items() if k.startswith("Datum") and k != "Datum Bis"
|
||||
and isinstance(v, str) and ISO_DATE.match(v)), None)
|
||||
if not starts or starts[:4] < since or SKIP_TERMIN.search(f"{kind_label} {row.get('Bezeichnung') or ''}"):
|
||||
continue
|
||||
title = row.get("Bezeichnung") or kind_label
|
||||
title = html_to_text(row.get("Bezeichnung")) or kind_label
|
||||
kind = next((k for pattern, k in TERMIN_KIND if pattern.search(f"{kind_label} {title}")), "public_event")
|
||||
chamber = {"Nationalrat": "NR", "Bundesrat": "BR"}.get(row.get("Gremium") or "")
|
||||
ends = next((v for k, v in row.items() if k.startswith("Datum Bis") and isinstance(v, str)
|
||||
|
||||
@@ -142,3 +142,19 @@ def test_firmenbuch_number():
|
||||
|
||||
assert firmenbuch_number("FN 306527 a") == firmenbuch_number("FN306527A") == firmenbuch_number("306527a") == "306527a"
|
||||
assert firmenbuch_number("ATU12345678") is None
|
||||
|
||||
|
||||
def test_parlament_calendar_titles_are_html_decoded():
|
||||
import json
|
||||
|
||||
from politrack.core.runner import make_response, parse_offline
|
||||
from politrack.sources.parlament.news import ParlamentCalendar
|
||||
|
||||
body = {"header": [{"label": "Datum"}, {"label": "Terminart"}, {"label": "Bezeichnung"}, {"label": "Gremium"},
|
||||
{"label": "Link"}, {"label": "WENTRY_ID"}],
|
||||
"rows": [["2026-06-10T09:00:00", "Plenarsitzung<BR>NR", "84. Sitzung des Nationalrates", "Nationalrat",
|
||||
"/termin/1", "1"]]}
|
||||
events = parse_offline(ParlamentCalendar(), make_response("https://www.parlament.gv.at/x", json.dumps(body).encode(), kind="list"),
|
||||
params={"since_year": 2026})
|
||||
assert [e.title for e in events] == ["84. Sitzung des Nationalrates"]
|
||||
assert events[0].description == "Plenarsitzung NR"
|
||||
Reference in new issue
Block a user