fix: show ZOPK facts from different source articles
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Pick one fact from each of the 3 most recent distinct articles instead of 3 facts from the same article. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
53965d3486
commit
7aff486de9
@ -128,15 +128,26 @@ def index():
|
||||
# Backward compat — next_event used by other parts
|
||||
next_event = upcoming_events[0]['event'] if upcoming_events else None
|
||||
|
||||
# ZOPK Knowledge facts — widget dla zalogowanych (najnowsze i najistotniejsze)
|
||||
# ZOPK Knowledge facts — widget dla zalogowanych (najnowsze z różnych źródeł)
|
||||
zopk_facts = []
|
||||
if current_user.is_authenticated:
|
||||
try:
|
||||
from database import ZOPKKnowledgeFact, ZOPKNews
|
||||
zopk_facts = db.query(ZOPKKnowledgeFact).join(ZOPKNews).filter(
|
||||
from sqlalchemy import distinct
|
||||
# Pobierz najnowszy fakt z każdego z 3 różnych artykułów
|
||||
recent_news_ids = db.query(distinct(ZOPKKnowledgeFact.source_news_id)).join(ZOPKNews).filter(
|
||||
ZOPKKnowledgeFact.confidence_score >= 0.5,
|
||||
ZOPKNews.published_at.isnot(None)
|
||||
).order_by(ZOPKNews.published_at.desc()).limit(3).all()
|
||||
news_ids = [r[0] for r in recent_news_ids]
|
||||
if news_ids:
|
||||
# Po jednym fakcie z każdego artykułu
|
||||
for nid in news_ids:
|
||||
fact = db.query(ZOPKKnowledgeFact).filter(
|
||||
ZOPKKnowledgeFact.source_news_id == nid
|
||||
).order_by(ZOPKKnowledgeFact.confidence_score.desc()).first()
|
||||
if fact:
|
||||
zopk_facts.append(fact)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user