fix: Cluster-Liste leer — Backend-Felder drucksachen/avg_gwoe_score
Backend liefert seit ueber den Refactor fields drucksachen/ avg_gwoe_score; Frontend-Template las members/avg_score → leere Cluster-Cards. Beide Schluessel akzeptieren (Backwards-Compat). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c3d4ab186f
commit
56c68d3398
@ -181,11 +181,15 @@ async function loadClusters() {
|
||||
}
|
||||
|
||||
function renderClusterCard(cl, idx) {
|
||||
const members = cl.members || [];
|
||||
const avgScore = cl.avg_score != null ? parseFloat(cl.avg_score).toFixed(1) : '—';
|
||||
// Backend liefert drucksachen+avg_gwoe_score; alte UI-Variante hatte members+avg_score.
|
||||
const members = cl.drucksachen || cl.members || [];
|
||||
const avgScoreRaw = cl.avg_gwoe_score != null ? cl.avg_gwoe_score : cl.avg_score;
|
||||
const avgScore = avgScoreRaw != null ? parseFloat(avgScoreRaw).toFixed(1) : '—';
|
||||
const label = cl.label || cl.title || ('Cluster ' + (idx + 1));
|
||||
const fraktionen = cl.fraktionen || {};
|
||||
const dom = cl.dominant_fraktion || '';
|
||||
const size = cl.size != null ? cl.size : members.length;
|
||||
|
||||
const fraktionen = cl.fraktionen || (dom ? {[dom]: size} : {});
|
||||
const frakBars = Object.entries(fraktionen)
|
||||
.sort((a, b) => b[1] - a[1])
|
||||
.slice(0, 5)
|
||||
@ -195,7 +199,7 @@ function renderClusterCard(cl, idx) {
|
||||
return `<div class="cluster-card" onclick="showCluster(${idx})">
|
||||
<h3>${label}</h3>
|
||||
<div class="cluster-meta">
|
||||
<span>${members.length} Antrag${members.length !== 1 ? 'e' : ''}</span>
|
||||
<span>${size} Antrag${size !== 1 ? 'e' : ''}</span>
|
||||
<span class="cluster-score">Ø ${avgScore}</span>
|
||||
</div>
|
||||
${frakBars ? `<div class="cluster-fraktionen">${frakBars}</div>` : ''}
|
||||
@ -211,28 +215,38 @@ function showCluster(idx) {
|
||||
const content = document.getElementById('cluster-detail-content');
|
||||
detail.style.display = '';
|
||||
|
||||
const members = cl.members || [];
|
||||
const members = cl.drucksachen || cl.members || [];
|
||||
const label = cl.label || cl.title || ('Cluster ' + (idx + 1));
|
||||
const avgScore = cl.avg_score != null ? parseFloat(cl.avg_score).toFixed(1) : '—';
|
||||
const avgScoreRaw = cl.avg_gwoe_score != null ? cl.avg_gwoe_score : cl.avg_score;
|
||||
const avgScore = avgScoreRaw != null ? parseFloat(avgScoreRaw).toFixed(1) : '—';
|
||||
const size = cl.size != null ? cl.size : members.length;
|
||||
|
||||
content.innerHTML = `
|
||||
<div style="margin-bottom:1rem;">
|
||||
<h2 style="font-family:var(--font-display);font-size:18px;color:var(--ecg-teal);">${label}</h2>
|
||||
<p style="font-family:var(--font-mono);font-size:12px;opacity:0.65;">
|
||||
${members.length} Anträge · Ø Score ${avgScore}
|
||||
${size} Anträge · Ø Score ${avgScore}
|
||||
</p>
|
||||
</div>
|
||||
<div role="list">
|
||||
${members.map(m => `
|
||||
<a href="/antrag/${encodeURIComponent(m.drucksache || m)}"
|
||||
class="v2-result-row" style="display:block;text-decoration:none;">
|
||||
${members.map(m => {
|
||||
// m kann String (Drucksache-ID) oder Objekt sein
|
||||
const isObj = typeof m === 'object' && m !== null;
|
||||
const ds = isObj ? (m.drucksache || '') : m;
|
||||
const bl = isObj ? (m.bundesland || '') : '';
|
||||
const titel = isObj ? (m.titel || ds) : ds;
|
||||
const score = isObj && m.gwoe_score != null ? parseFloat(m.gwoe_score).toFixed(1) : null;
|
||||
const url = `/antrag/${encodeURIComponent(ds)}` + (bl ? `?bundesland=${encodeURIComponent(bl)}` : '');
|
||||
return `
|
||||
<a href="${url}" class="v2-result-row" style="display:block;text-decoration:none;">
|
||||
<div class="v2-result-meta">
|
||||
<span class="v2-chip" style="font-size:10px;">${m.bundesland || ''}</span>
|
||||
<span style="font-size:11px;opacity:0.6;font-family:var(--font-mono);">${m.drucksache || m}</span>
|
||||
${bl ? `<span class="v2-chip" style="font-size:10px;">${bl}</span>` : ''}
|
||||
<span style="font-size:11px;opacity:0.6;font-family:var(--font-mono);">${ds}</span>
|
||||
</div>
|
||||
<div class="v2-result-title">${m.titel || m.drucksache || m}</div>
|
||||
${m.gwoe_score != null ? `<div style="font-family:var(--font-mono);font-size:12px;color:var(--ecg-teal);font-weight:700;">Score ${parseFloat(m.gwoe_score).toFixed(1)}</div>` : ''}
|
||||
</a>`).join('')}
|
||||
<div class="v2-result-title">${titel}</div>
|
||||
${score ? `<div style="font-family:var(--font-mono);font-size:12px;color:var(--ecg-teal);font-weight:700;">Score ${score}</div>` : ''}
|
||||
</a>`;
|
||||
}).join('')}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user