feat: 工参属性全部由 OpenCode 同一条 SQL 导出;即席查询表没有时间列时不加时间条件
即席查询的 4G/5G 小区工参表没有日期列、4G 只有当前记录,取不到历史日工参,工参不再走即席查询。即席查询的表配置写了 time_field 而表里没有这一列时,按页面做法不带时间条件。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import json
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -27,6 +28,20 @@ def test_result_json_carries_table_params_like_the_page():
|
||||
assert payload["result"][0]["feild"] == "cgi" and payload["result"][0]["table"] == HEAD["tablename"]
|
||||
|
||||
|
||||
def test_where_skips_time_when_table_has_no_time_column():
|
||||
gongcan = [{**HEAD, "time_field": "starttime", "city_field": "city"}, {**HEAD, "columnname": "cell_name"}]
|
||||
kpi = [{**HEAD, "columnname": "starttime", "time_field": "starttime"}, {**HEAD, "columnname": "cgi"}]
|
||||
assert not adhoc._has_time_column(gongcan) and adhoc._has_time_column(kpi)
|
||||
start, end = adhoc.time_window("prev_day", 1, date(2026, 11, 11))
|
||||
assert [item["feild"] for item in adhoc._where(gongcan[0], start, end, "江门", timed=False)] == ["city"]
|
||||
timed = adhoc._where(kpi[0], start, end, "江门")
|
||||
assert [(item["feild"], item["symbol"], item["val"]) for item in timed] == [
|
||||
("starttime", ">=", "2026-11-10 00:00:00"),
|
||||
("starttime", "<", "2026-11-10 23:59:59"),
|
||||
("city", "in", "江门"),
|
||||
]
|
||||
|
||||
|
||||
def test_count_sends_indexcount_and_rejects_error_payload(monkeypatch):
|
||||
sent = []
|
||||
replies = [{"count": 37604, "indexcount": "0"}, {"stat": "0", "message": "null"}, {}]
|
||||
|
||||
Reference in New Issue
Block a user