From e9cb384999294883b319458967194660c12efa49 Mon Sep 17 00:00:00 2001 From: Lloyd Date: Fri, 7 Nov 2025 22:47:47 +0000 Subject: [PATCH] fix: simplify parameter handling in packet stats and recent packets endpoints --- repeater/web/api_endpoints.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/repeater/web/api_endpoints.py b/repeater/web/api_endpoints.py index b348f01..b6035d3 100644 --- a/repeater/web/api_endpoints.py +++ b/repeater/web/api_endpoints.py @@ -214,9 +214,9 @@ class APIEndpoints: @cherrypy.expose @cherrypy.tools.json_out() - def packet_stats(self): + def packet_stats(self, hours=24): try: - hours = int(cherrypy.request.params.get('hours', 24)) + hours = int(hours) stats = self._get_storage().get_packet_stats(hours=hours) return self._success(stats) except Exception as e: @@ -225,9 +225,9 @@ class APIEndpoints: @cherrypy.expose @cherrypy.tools.json_out() - def recent_packets(self): + def recent_packets(self, limit=100): try: - limit = int(cherrypy.request.params.get('limit', 100)) + limit = int(limit) packets = self._get_storage().get_recent_packets(limit=limit) return self._success(packets, count=len(packets)) except Exception as e: @@ -267,9 +267,9 @@ class APIEndpoints: @cherrypy.expose @cherrypy.tools.json_out() - def packet_type_stats(self): + def packet_type_stats(self, hours=24): try: - hours = int(cherrypy.request.params.get('hours', 24)) + hours = int(hours) stats = self._get_storage().get_packet_type_stats(hours=hours) return self._success(stats) except Exception as e: