feat: add info about article relevance to the news page
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
Steven Tischer
2026-06-17 13:18:08 +02:00
parent 23da3e44ba
commit b6618e030e
4 changed files with 56 additions and 4 deletions
+3 -3
View File
@@ -74,7 +74,7 @@ def get_news_by_id(news_id: str) -> NewsArticleDetail:
)
def _get_postproc_labels(news_id: str) -> tuple[bool, list]:
def _get_postproc_labels(news_id: str) -> tuple[bool | None, list]:
try:
response = elasticsearch.search(
index="aktuell_postproc",
@@ -85,11 +85,11 @@ def _get_postproc_labels(news_id: str) -> tuple[bool, list]:
)
except Exception:
logger.exception(f"Postproc-Lookup for {news_id} failed.")
return False, []
return None, []
hits = response.get("hits", {}).get("hits", [])
if not hits:
return False, []
return None, []
postproc_source = hits[0].get("_source", {})
relevant = bool(postproc_source.get("relevant", 0))
+1 -1
View File
@@ -16,7 +16,7 @@ class NewsArticle(BaseModel):
class NewsArticleDetail(NewsArticle):
full_content: Optional[str] = None
relevant: bool = False
relevant: Optional[bool] = None
authors: List[str] = []
@@ -33,6 +33,23 @@
}
</div>
<p class="article-heading">{{ article.maintitle || 'Kein Titel' }}</p>
@if (article.relevant === true) {
<span class="relevance-badge is-relevant">
<mat-icon>check_circle</mat-icon>
Relevant
</span>
} @else if (article.relevant === false) {
<span class="relevance-badge not-relevant">
<mat-icon>cancel</mat-icon>
Nicht relevant
</span>
} @else {
<span class="relevance-badge undetermined">
<mat-icon>help</mat-icon>
Relevanz nicht bestimmt
</span>
}
</header>
<div class="article-body">
@@ -87,6 +87,41 @@ main {
line-height: 1.3;
}
.relevance-badge {
display: inline-flex;
align-items: center;
gap: 6px;
margin-top: 14px;
padding: 5px 12px;
border-radius: 999px;
font-size: 13px;
font-weight: 600;
mat-icon {
font-size: 16px;
width: 16px;
height: 16px;
}
&.is-relevant {
background: #effaf3;
border: 1px solid #bdebcf;
color: #24834f;
}
&.not-relevant {
background: var(--sg-surface-muted);
border: 1px solid #e2e2e2;
color: var(--sg-text-muted);
}
&.undetermined {
background: #fff7e8;
border: 1px solid #ffd796;
color: #c67500;
}
}
.article-body {
font-size: 15px;
line-height: 1.7;