docs: история 2026-06-10 — speed-test, адаптивный интервал, threading lock
This commit is contained in:
@@ -114,6 +114,7 @@ class Database:
|
||||
elm_desc TEXT,
|
||||
protocol TEXT,
|
||||
voltage TEXT,
|
||||
response_time_ms INTEGER DEFAULT 250,
|
||||
supported TEXT,
|
||||
unsupported TEXT,
|
||||
errors TEXT,
|
||||
@@ -129,6 +130,7 @@ class Database:
|
||||
|
||||
# Миграции: добавляем колонки, которых нет в старых БД
|
||||
migrations = [
|
||||
"ALTER TABLE device_profiles ADD COLUMN response_time_ms INTEGER DEFAULT 250",
|
||||
"ALTER TABLE sessions ADD COLUMN device_uuid TEXT",
|
||||
"ALTER TABLE sessions ADD COLUMN phone_lang TEXT",
|
||||
"ALTER TABLE sessions ADD COLUMN phone_tz TEXT",
|
||||
@@ -286,25 +288,27 @@ class Database:
|
||||
def save_device_profile(self, mac: str, profile: dict):
|
||||
"""Сохраняет или обновляет профиль устройства.
|
||||
|
||||
profile — результат obd.probe.probe().
|
||||
profile — результат obd.probe.probe() + response_time_ms.
|
||||
"""
|
||||
with self._lock:
|
||||
now = datetime.now(timezone.utc).isoformat()
|
||||
self.conn.execute("""
|
||||
INSERT INTO device_profiles
|
||||
(mac, level, elm_version, elm_desc, protocol, voltage,
|
||||
supported, unsupported, errors, first_seen, last_seen)
|
||||
VALUES (?,?,?,?,?,?, ?,?,?, ?,?)
|
||||
response_time_ms, supported, unsupported, errors,
|
||||
first_seen, last_seen)
|
||||
VALUES (?,?,?,?,?,?, ?,?,?,?, ?,?)
|
||||
ON CONFLICT(mac) DO UPDATE SET
|
||||
level = excluded.level,
|
||||
elm_version = excluded.elm_version,
|
||||
elm_desc = excluded.elm_desc,
|
||||
protocol = excluded.protocol,
|
||||
voltage = excluded.voltage,
|
||||
supported = excluded.supported,
|
||||
unsupported = excluded.unsupported,
|
||||
errors = excluded.errors,
|
||||
last_seen = excluded.last_seen
|
||||
level = excluded.level,
|
||||
elm_version = excluded.elm_version,
|
||||
elm_desc = excluded.elm_desc,
|
||||
protocol = excluded.protocol,
|
||||
voltage = excluded.voltage,
|
||||
response_time_ms = excluded.response_time_ms,
|
||||
supported = excluded.supported,
|
||||
unsupported = excluded.unsupported,
|
||||
errors = excluded.errors,
|
||||
last_seen = excluded.last_seen
|
||||
""", (
|
||||
mac,
|
||||
profile.get("level", -1),
|
||||
@@ -312,6 +316,7 @@ class Database:
|
||||
profile.get("elm_desc"),
|
||||
profile.get("protocol"),
|
||||
profile.get("voltage"),
|
||||
profile.get("response_time_ms", 250),
|
||||
json.dumps(profile.get("supported", []), ensure_ascii=False),
|
||||
json.dumps(profile.get("unsupported", []), ensure_ascii=False),
|
||||
json.dumps(profile.get("errors", []), ensure_ascii=False),
|
||||
|
||||
Reference in New Issue
Block a user