fix: fix 500 error on homepage from ZOPK facts query
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
Replace broken distinct() call with group_by() and add db.rollback() in except handler to prevent failed transaction from cascading. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7aff486de9
commit
39fc5e0fac
@ -133,23 +133,25 @@ def index():
|
||||
if current_user.is_authenticated:
|
||||
try:
|
||||
from database import ZOPKKnowledgeFact, ZOPKNews
|
||||
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(
|
||||
recent_news_ids = db.query(
|
||||
ZOPKKnowledgeFact.source_news_id
|
||||
).join(ZOPKNews).filter(
|
||||
ZOPKKnowledgeFact.confidence_score >= 0.5,
|
||||
ZOPKNews.published_at.isnot(None)
|
||||
).group_by(
|
||||
ZOPKKnowledgeFact.source_news_id, ZOPKNews.published_at
|
||||
).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()
|
||||
).first()
|
||||
if fact:
|
||||
zopk_facts.append(fact)
|
||||
except Exception:
|
||||
pass
|
||||
db.rollback()
|
||||
|
||||
# Sprawdź czy użytkownik ma deklarację członkowską w toku
|
||||
pending_application = None
|
||||
|
||||
Loading…
Reference in New Issue
Block a user