feat: 完善登录保持、栅格下载和任务调度
This commit is contained in:
@@ -122,6 +122,18 @@ _LTE_GROUPS: dict[str, tuple[str, tuple[tuple[str, str], ...]]] = {
|
||||
|
||||
GROUP_ORDER = ("rsrp", "dlsinr", "worse", "cover", "weak", "samples")
|
||||
|
||||
GRID_SIZES = {
|
||||
"GRID20": ("20米", "20米栅格ID", "grid20_id"),
|
||||
"GRID50": ("50米", "50米栅格ID", "grid50_id"),
|
||||
}
|
||||
|
||||
|
||||
def grid_spec(grid_size: str) -> tuple[str, str, str]:
|
||||
try:
|
||||
return GRID_SIZES[grid_size]
|
||||
except KeyError as exc:
|
||||
raise ValueError("栅格只支持 20米或50米") from exc
|
||||
|
||||
|
||||
def group_table(network: str) -> dict[str, tuple[str, tuple[tuple[str, str], ...]]]:
|
||||
if network == "LTE":
|
||||
@@ -145,13 +157,19 @@ def cell_columns(network: str) -> list[Column]:
|
||||
]
|
||||
|
||||
|
||||
def columns_for(network: str, groups: list[str] | None) -> list[Column]:
|
||||
def columns_for(network: str, groups: list[str] | None, grid_size: str = "GRID20") -> list[Column]:
|
||||
table = group_table(network)
|
||||
_label, id_label, id_field = grid_spec(grid_size)
|
||||
selected = [item for item in GROUP_ORDER if groups is None or item in groups]
|
||||
unknown = [item for item in (groups or []) if item not in table]
|
||||
if unknown:
|
||||
raise ValueError("未知的下载项目: " + "、".join(unknown))
|
||||
columns = [Column(label, field, "grid") for label, field in IDENTITY]
|
||||
columns = []
|
||||
for label, field in IDENTITY:
|
||||
if field == "grid20_id":
|
||||
columns.append(Column(id_label, id_field, "grid"))
|
||||
else:
|
||||
columns.append(Column(label, field, "grid"))
|
||||
seen = {column.field for column in columns}
|
||||
for key in selected:
|
||||
for label, field in table[key][1]:
|
||||
|
||||
Reference in New Issue
Block a user