mirror of
https://github.com/rightup/pyMC_Repeater.git
synced 2026-03-28 17:43:06 +01:00
fix: simplify parameter handling in packet stats and recent packets endpoints
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user