🌊 Волна 11: backend N+1 + метрики (5 багов)
- online_now_counts_all_today_logins: убрана ветка daily_logins, фильтр 30 мин (admin.py) - assistant_personal_stats_n_plus_1: 36 → 6 запросов через GROUP BY (assistant.py) - learning_get_lesson_n_plus_1: ANY + группировка options, + get_topic_test (learning.py) - feed_attachment_order_collision: MAX(order_number)+1 + UNIQUE (feed.py + database.py) - admin_content_summary_n_plus_1: 30 → 6 запросов через GROUP BY (admin_content.py) Аудит v2: Issue #5, backend 10/10 задач — закрыто!
This commit is contained in:
+9
-1
@@ -650,6 +650,15 @@ async def admin_upload_feed_image(
|
||||
f"Max {MAX_FEED_ATTACHMENTS} attachments per post (already {current_count})",
|
||||
)
|
||||
|
||||
# 🔧 ФИКС (24.09.2026): feed_attachment_order_collision —
|
||||
# раньше order_number = current_count. Если удалить order=0 и загрузить новое,
|
||||
# новое получит order=1, что конфликтует с уже существующим order=1.
|
||||
# Теперь MAX(order_number) + 1.
|
||||
max_order = await conn.fetchval("""
|
||||
SELECT COALESCE(MAX(order_number), -1) FROM feed_attachments WHERE post_id = $1
|
||||
""", post_id)
|
||||
order_number = max_order + 1
|
||||
|
||||
# Готовим имя файла: {post_id}_{order}_{uuid8}.{ext}
|
||||
ext_map = {
|
||||
"image/jpeg": "jpg",
|
||||
@@ -659,7 +668,6 @@ async def admin_upload_feed_image(
|
||||
"image/gif": "gif",
|
||||
}
|
||||
ext = ext_map.get(content_type, "jpg")
|
||||
order_number = current_count # 0, 1, 2
|
||||
filename = f"{post_id}_{order_number}_{uuid.uuid4().hex[:8]}.{ext}"
|
||||
|
||||
# Сохраняем на диск
|
||||
|
||||
Reference in New Issue
Block a user