fix: views_count increment no longer triggers updated_at on classifieds
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

Use raw SQL UPDATE for views_count to bypass SQLAlchemy onupdate.
Restore updated_at display in homepage cards - now accurate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-04-10 07:43:09 +02:00
parent 8dcf4de146
commit 79c76b1337
2 changed files with 7 additions and 3 deletions

View File

@ -166,8 +166,12 @@ def view(classified_id):
flash('Ogłoszenie nie istnieje.', 'error')
return redirect(url_for('.classifieds_index'))
# Zwiększ licznik wyświetleń (handle NULL)
classified.views_count = (classified.views_count or 0) + 1
# Zwiększ licznik wyświetleń bez triggerowania updated_at
db.execute(
Classified.__table__.update().where(Classified.id == classified_id).values(
views_count=(Classified.views_count + 1)
)
)
# Zapisz odczyt przez zalogowanego użytkownika
existing_read = db.query(ClassifiedRead).filter(

View File

@ -1302,7 +1302,7 @@
<span class="new-card-badge b2b">🏢 B2B {% if cl.listing_type == 'szukam' %}Szukam{% else %}Oferuję{% endif %}</span>
<div class="new-card-title">{{ cl.title }}</div>
<div class="new-card-meta">
{{ cl.author.name if cl.author else 'Anonim' }} · {{ cl.created_at|local_time('%d.%m.%Y') }}
{{ cl.author.name if cl.author else 'Anonim' }} · {{ (cl.updated_at or cl.created_at)|local_time('%d.%m.%Y') }}
</div>
</a>
{% endfor %}