mirror of
https://github.com/pablorevilla-meshtastic/meshview.git
synced 2026-10-30 18:51:57 +01:00
ruff
This commit is contained in:
1 parent
7edb7b5c38
commit
8bea2bd744
3 files changed
+8
-16
No files matched your search
+3
-13
@@ -40,7 +40,6 @@ async def get_packets(
|
||||
"""
|
||||
|
||||
async with database.async_session() as session:
|
||||
|
||||
stmt = select(models.Packet)
|
||||
conditions = []
|
||||
|
||||
@@ -55,10 +54,7 @@ async def get_packets(
|
||||
# Legacy node ID filter: match either direction
|
||||
if node_id is not None:
|
||||
conditions.append(
|
||||
or_(
|
||||
models.Packet.from_node_id == node_id,
|
||||
models.Packet.to_node_id == node_id
|
||||
)
|
||||
or_(models.Packet.from_node_id == node_id, models.Packet.to_node_id == node_id)
|
||||
)
|
||||
|
||||
# Port filter
|
||||
@@ -72,9 +68,7 @@ async def get_packets(
|
||||
# Case-insensitive substring search on UTF-8 payload (stored as BLOB)
|
||||
if contains:
|
||||
contains_lower = contains.lower()
|
||||
conditions.append(
|
||||
func.lower(models.Packet.payload).like(f"%{contains_lower}%")
|
||||
)
|
||||
conditions.append(func.lower(models.Packet.payload).like(f"%{contains_lower}%"))
|
||||
|
||||
# Apply all conditions
|
||||
if conditions:
|
||||
@@ -393,15 +387,11 @@ async def get_channels_in_period(period_type: str = "hour", length: int = 24):
|
||||
|
||||
result = await session.execute(stmt)
|
||||
|
||||
channels = [
|
||||
ch for ch in result.scalars().all()
|
||||
if ch is not None
|
||||
]
|
||||
channels = [ch for ch in result.scalars().all() if ch is not None]
|
||||
|
||||
return channels
|
||||
|
||||
|
||||
|
||||
async def get_total_packet_count(
|
||||
period_type: str | None = None,
|
||||
length: int | None = None,
|
||||
|
||||
@@ -193,6 +193,7 @@ async def index(request):
|
||||
starting_url = CONFIG["site"].get("starting", "/map") # default to /map if not set
|
||||
raise web.HTTPFound(location=starting_url)
|
||||
|
||||
|
||||
# redirect for backwards compatibility
|
||||
@routes.get("/packet_list/{packet_id}")
|
||||
async def redirect_packet_list(request):
|
||||
@@ -275,6 +276,7 @@ async def top(request):
|
||||
content_type="text/html",
|
||||
)
|
||||
|
||||
|
||||
@routes.get("/stats")
|
||||
async def stats(request):
|
||||
template = env.get_template("stats.html")
|
||||
@@ -391,6 +393,7 @@ async def graph_traceroute(request):
|
||||
content_type="image/svg+xml",
|
||||
)
|
||||
|
||||
|
||||
'''
|
||||
@routes.get("/stats")
|
||||
async def stats(request):
|
||||
@@ -415,6 +418,7 @@ async def stats(request):
|
||||
)
|
||||
'''
|
||||
|
||||
|
||||
async def run_server():
|
||||
# Wait for database migrations to complete before starting web server
|
||||
logger.info("Checking database schema status...")
|
||||
|
||||
@@ -197,8 +197,7 @@ async def api_packets(request):
|
||||
|
||||
# --- Sort descending by import_time_us ---
|
||||
ui_packets.sort(
|
||||
key=lambda p: (p.import_time_us is not None, p.import_time_us or 0),
|
||||
reverse=True
|
||||
key=lambda p: (p.import_time_us is not None, p.import_time_us or 0), reverse=True
|
||||
)
|
||||
ui_packets = ui_packets[:limit]
|
||||
|
||||
@@ -253,7 +252,6 @@ async def api_packets(request):
|
||||
return web.json_response({"error": "Failed to fetch packets"}, status=500)
|
||||
|
||||
|
||||
|
||||
@routes.get("/api/stats")
|
||||
async def api_stats(request):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user