feat(web): стабилизация UI, Gemini-скроллинг, роутеры контекста/снапшотов и актуализация роадмапа
This commit is contained in:
@@ -47,6 +47,8 @@ def get_or_create_snapshot_id(snapshot_time: str, date_str: str = None, is_yeste
|
||||
|
||||
with get_connection() as conn:
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 1. Проверяем, существует ли уже срез с точно таким же временем и датой
|
||||
if date_str:
|
||||
cursor.execute(
|
||||
"SELECT snapshot_id FROM scud_logs WHERE log_date = ? AND snapshot_time = ? AND snapshot_id IS NOT NULL LIMIT 1",
|
||||
@@ -62,19 +64,30 @@ def get_or_create_snapshot_id(snapshot_time: str, date_str: str = None, is_yeste
|
||||
if row and row[0]:
|
||||
return row[0]
|
||||
|
||||
# 2. Извлекаем ВСЕ существующие ID за текущие календарные сутки
|
||||
cursor.execute("""
|
||||
SELECT snapshot_id FROM scud_logs
|
||||
SELECT DISTINCT snapshot_id
|
||||
FROM scud_logs
|
||||
WHERE snapshot_id LIKE ? OR snapshot_id LIKE ?
|
||||
ORDER BY snapshot_id DESC LIMIT 1
|
||||
""", (f"{date_prefix}-%", f"Y{date_prefix}-%"))
|
||||
|
||||
rows = cursor.fetchall()
|
||||
max_seq = 0
|
||||
|
||||
last_row = cursor.fetchone()
|
||||
next_seq = 1
|
||||
if last_row and last_row[0]:
|
||||
parts = last_row[0].replace("Y", "").split("-")
|
||||
if len(parts) > 1 and parts[1].isdigit():
|
||||
next_seq = int(parts[1]) + 1
|
||||
for (s_id,) in rows:
|
||||
if not s_id:
|
||||
continue
|
||||
try:
|
||||
# Извлекаем число после последнего дефиса
|
||||
parts = str(s_id).split('-')
|
||||
if len(parts) >= 2 and parts[-1].isdigit():
|
||||
num = int(parts[-1])
|
||||
if num > max_seq:
|
||||
max_seq = num
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
next_seq = max_seq + 1
|
||||
return f"{prefix}{date_prefix}-{next_seq:03d}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user