This commit is contained in:
2026-05-28 12:34:01 -04:00
parent d239de257d
commit 49310e6d59
9 changed files with 240 additions and 164 deletions
+57
View File
@@ -166,6 +166,63 @@ def set_p3p_pair(test_row_id, p3p_pair):
)
def update_all_p3p_pairs_sql():
with _tx():
cursor = _conn.execute(
"""
UPDATE tests AS t
SET p3p_pair = (
SELECT CASE
WHEN COUNT(*) = 0 THEN '[]'
ELSE '[' || GROUP_CONCAT('"' || m.device || '_' || m.test_id || '"') || ']'
END
FROM tests AS m
WHERE m.interference = 'P3P'
AND UPPER(m.device) = UPPER(t.device)
AND UPPER(m.test_id) = CASE
WHEN INSTR(UPPER(t.test_id), 'TH') > 0 THEN REPLACE(UPPER(t.test_id), 'TH', 'UT')
WHEN INSTR(UPPER(t.test_id), 'UT') > 0 THEN REPLACE(UPPER(t.test_id), 'UT', 'TH')
ELSE '__NO_MATCH__'
END
)
WHERE t.interference = 'P3P'
"""
)
return cursor.rowcount
def update_all_p2p_coe_pairs_sql():
with _tx():
cursor = _conn.execute(
"""
UPDATE tests AS t
SET coe_pair = (
SELECT CASE
WHEN COUNT(*) = 0 THEN '[]'
ELSE '[' || GROUP_CONCAT('"' || pair_value || '"') || ']'
END
FROM (
SELECT DISTINCT m.device || '_' || m.test_id AS pair_value
FROM tests AS m
WHERE m.interference = 'COE'
AND IFNULL(m.device, '') = IFNULL(t.device, '')
AND IFNULL(m.rotation, '') = IFNULL(t.rotation, '')
AND IFNULL(m.test_point, '') = IFNULL(t.test_point, '')
AND IFNULL(m.rssi, '') = IFNULL(t.rssi, '')
AND IFNULL(m.station, '') = IFNULL(t.station, '')
AND IFNULL(m.band, '') = IFNULL(t.band, '')
AND IFNULL(m.channel, '') = IFNULL(t.channel, '')
AND IFNULL(m.bandwidth, '') = IFNULL(t.bandwidth, '')
AND IFNULL(m.direction, '') = IFNULL(t.direction, '')
ORDER BY pair_value
)
)
WHERE t.interference = 'P2P'
"""
)
return cursor.rowcount
def get_station_for_test(test_id, device):
with _lock:
row = _conn.execute(