Politrack: track Austrian politicians from public sources
Initial import of Politrack, a self-hosted service that tracks Austrian politicians from federal to municipal level - roles, votes, money flows, statements, meetings, social media and legal proceedings - with every claim linked to its sources. - backend: FastAPI + Postgres/pgvector; adapter framework (fetch -> parse -> load -> enrich) with robots.txt/TDM-aware fetching, a raw-response archive for reparsing, and a claim/evidence model with corroboration - sources: Parliament, Wikidata, EU Parliament/Commission, Council of Ministers, Rechnungshof party reports and donations, procurement, RTR media transparency, political ad libraries, WKStA, news feeds, Wikipedia edits, Bluesky, Mastodon, public Telegram channels, YouTube and X (official API) - web: Next.js frontend in German and English with typed API client - mcp: MCP server for AI agents and RAG - docs: architecture, data model, sources, legal notes, Unraid deployment and contributor guides; Docker Compose setup for Unraid Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
583ccba31c
187 files changed
+39890
No files matched your search
@@ -0,0 +1,191 @@
|
||||
import type {Metadata} from 'next';
|
||||
import {notFound} from 'next/navigation';
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {ClaimList} from '@/components/ClaimList';
|
||||
import {SocialFeed} from '@/components/SocialFeed';
|
||||
import {VoteTable} from '@/components/VoteTable';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api, NotFoundError, type PartyDetail} from '@/lib/api';
|
||||
import {formatDate, formatMoney} from '@/lib/format';
|
||||
|
||||
type Props = {params: Promise<{locale: string; slug: string}>};
|
||||
|
||||
async function loadParty(slug: string): Promise<PartyDetail> {
|
||||
try {
|
||||
return await api.party(slug);
|
||||
} catch (error) {
|
||||
if (error instanceof NotFoundError) notFound();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateMetadata({params}: Props): Promise<Metadata> {
|
||||
const {slug} = await params;
|
||||
const party = await loadParty(slug);
|
||||
return {title: party.short_name ?? party.name};
|
||||
}
|
||||
|
||||
export default async function PartyPage({params}: Props) {
|
||||
const {locale, slug} = await params;
|
||||
setRequestLocale(locale);
|
||||
const t = await getTranslations('Parties');
|
||||
const tv = await getTranslations('Votes');
|
||||
const tl = await getTranslations('Persons');
|
||||
const tm = await getTranslations('Money');
|
||||
const party = await loadParty(slug);
|
||||
const [votes, claims, posts] = await Promise.all([
|
||||
api.votes({party: slug, limit: 15}),
|
||||
api.claims({party: slug, types: ['donation', 'media_mention', 'legal_proceeding', 'money_flow', 'lobbying'], limit: 30}),
|
||||
api.social({party: slug, limit: 5})
|
||||
]);
|
||||
const years = [...new Set(party.money_by_year.map((row) => row.year))].sort((a, b) => b - a);
|
||||
const kinds = [...new Set(party.money_by_year.map((row) => row.kind))];
|
||||
const cell = (year: number, kind: string) => party.money_by_year.find((row) => row.year === year && row.kind === kind);
|
||||
|
||||
return (
|
||||
<article>
|
||||
<h1 style={{borderBottomColor: party.color ?? undefined}} className="party-title">
|
||||
{party.short_name ?? party.name} <span className="muted small">{party.short_name && party.name}</span>
|
||||
</h1>
|
||||
|
||||
<div className="grid-2">
|
||||
<section>
|
||||
<h2>{t('members')} ({party.members.length})</h2>
|
||||
<ul className="compact">
|
||||
{party.members.slice(0, 200).map((m) => (
|
||||
<li key={m.slug}>
|
||||
<Link href={`/personen/${m.slug}`}>{m.full_name}</Link>{' '}
|
||||
<span className="muted small">
|
||||
{m.role === 'mp' ? m.body : m.role} · {tl(`level.${m.level}` as 'level.other')}
|
||||
{m.region && <> · {m.region}</>}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>{t('money')}</h2>
|
||||
{years.length ? (
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>{t('year')}</th>{kinds.map((kind) => <th key={kind}>{tm(`kind.${kind}` as 'kind.other')}</th>)}</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{years.map((year) => (
|
||||
<tr key={year}>
|
||||
<td>{year}</td>
|
||||
{kinds.map((kind) => {
|
||||
const row = cell(year, kind);
|
||||
return (
|
||||
<td key={kind} className="num" title={row ? `${row.count}×` : undefined}>
|
||||
{row?.total ? formatMoney(row.total, locale) : row ? `${row.count}×` : ''}
|
||||
</td>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
) : <p className="muted">–</p>}
|
||||
<p className="small"><Link href={`/geld?org=${slug}`}>→ {t('allMoney')}</Link></p>
|
||||
|
||||
<h2>{t('voteStats')}</h2>
|
||||
<p>
|
||||
{party.vote_stats.map((s) => (
|
||||
<span key={s.position} className={`pos pos-${s.position}`}>{tv(s.position as 'for')}: {s.count}</span>
|
||||
))}
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{(party.finance.length > 0 || party.related.length > 0) && (
|
||||
<div className="grid-2">
|
||||
{party.finance.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('finance')}</h2>
|
||||
<table>
|
||||
<tbody>
|
||||
{party.finance.map((f) => (
|
||||
<tr key={String(f.data.year ?? f.valid_from)}>
|
||||
<td>{String(f.data.year ?? formatDate(f.valid_from, locale))}</td>
|
||||
<td className="num">
|
||||
{f.data.total_income ? `${t('income')} ${formatMoney(Number(f.data.total_income), locale)}` : ''}
|
||||
</td>
|
||||
<td className="num">
|
||||
{f.data.total_expenses ? `${t('expenses')} ${formatMoney(Number(f.data.total_expenses), locale)}` : ''}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
)}
|
||||
{party.related.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('related')}</h2>
|
||||
<ul className="compact">
|
||||
{party.related.map((org) => (
|
||||
<li key={`${org.claim_type}-${org.slug}`}>
|
||||
<Link href={`/organisationen/${org.slug}`}>{org.name}</Link>{' '}
|
||||
<span className="muted small">({t(`relation.${org.claim_type}` as 'relation.affiliation')})</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid-2">
|
||||
<section>
|
||||
<h2>{t('formerMembers')}</h2>
|
||||
<ul className="compact">
|
||||
{party.former_members.map((m) => (
|
||||
<li key={m.slug}>
|
||||
<Link href={`/personen/${m.slug}?tab=media`}>{m.full_name}</Link>{' '}
|
||||
<span className="muted small">
|
||||
{m.last_office_end && `${tl('lastOffice', {date: formatDate(m.last_office_end, locale)})}`}
|
||||
{m.last_mention && ` · ${formatDate(m.last_mention, locale)}`}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p><Link href={`/ehemalige?party=${slug}`}>→ {t('formerMembers')}</Link></p>
|
||||
</section>
|
||||
{party.dissent.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('dissent')}</h2>
|
||||
<ul className="compact">
|
||||
{party.dissent.map((d) => (
|
||||
<li key={d.slug}>
|
||||
<Link href={`/personen/${d.slug}?tab=votes`}>{d.full_name}</Link>{' '}
|
||||
<span className="muted small">({d.dissenting_votes})</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h2>{t('recentVotes')}</h2>
|
||||
<VoteTable votes={votes} />
|
||||
<p><Link href={`/abstimmungen?party=${slug}`}>→ {tv('title')}</Link></p>
|
||||
</section>
|
||||
|
||||
{posts.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('channels')}</h2>
|
||||
<SocialFeed posts={posts} />
|
||||
<p><Link href={`/social?party=${slug}`}>→ {t('allPosts')}</Link></p>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section>
|
||||
<h2>{t('claims')}</h2>
|
||||
<ClaimList claims={claims} showSubject={false} />
|
||||
</section>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user