feat: add info about article relevance to the news page
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user