today stats
This commit is contained in:
parent
51968a1c8f
commit
fa8868f715
@ -49,5 +49,13 @@ class Events:
|
|||||||
cw.writerow(row)
|
cw.writerow(row)
|
||||||
return si.getvalue()
|
return si.getvalue()
|
||||||
|
|
||||||
|
def today_json(self):
|
||||||
|
values = self.collection.find({"date": self.today})
|
||||||
|
values = {value['event']: value['count'] for value in values}
|
||||||
|
json_data = {}
|
||||||
|
for metric in self.metrics:
|
||||||
|
json_data[metric] = values.get(metric) or 0
|
||||||
|
return json_data
|
||||||
|
|
||||||
|
|
||||||
events = Events()
|
events = Events()
|
||||||
|
4
main.py
4
main.py
@ -28,4 +28,8 @@ def run():
|
|||||||
output.headers["Content-type"] = "text/csv"
|
output.headers["Content-type"] = "text/csv"
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@app.route('/stats/today', methods=["GET"])
|
||||||
|
def today():
|
||||||
|
return events.today_json()
|
||||||
|
|
||||||
app.run(host="0.0.0.0", port=8000)
|
app.run(host="0.0.0.0", port=8000)
|
||||||
|
Loading…
Reference in New Issue
Block a user