fix: Fix AttributeError in report_categories
- Add .label('category') to SQLAlchemy query for proper Row attribute access
- Change filter_by to filter() for better NULL handling
Fixes 500 error on /raporty/struktura-branzowa
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2f37267475
commit
14e969bc6d
6
app.py
6
app.py
@ -8740,7 +8740,7 @@ def report_categories():
|
||||
try:
|
||||
# Grupowanie po kategoriach
|
||||
category_counts = db.query(
|
||||
Company.category,
|
||||
Company.category.label('category'),
|
||||
func.count(Company.id).label('count')
|
||||
).group_by(Company.category).all()
|
||||
|
||||
@ -8749,8 +8749,8 @@ def report_categories():
|
||||
categories = []
|
||||
for cat in category_counts:
|
||||
cat_name = cat.category or 'Brak kategorii'
|
||||
examples = db.query(Company.name).filter_by(
|
||||
category=cat.category
|
||||
examples = db.query(Company.name).filter(
|
||||
Company.category == cat.category
|
||||
).limit(3).all()
|
||||
|
||||
categories.append({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user