Modify /chat_activity

This commit is contained in:
hok7z 2022-12-21 22:41:28 +02:00
parent add2351bee
commit 6baefaeac1
1 changed files with 9 additions and 9 deletions

View File

@ -41,6 +41,9 @@ def top_users():
@group_stat_api.route("/chat_activity", methods=["GET"])
def chat_activity():
dates = []
counts = []
from_date = request.args.get("from_date")
to_date = request.args.get("to_date")
@ -50,13 +53,10 @@ def chat_activity():
}),422
date_format = request.args.get("date_format")
group_by = request.args.get("group_by")
group_by = group_by if group_by else "day"
date_format = date_format if date_format else "%Y-%m-%d"
dates = []
counts = []
group_by = request.args.get("group_by")
group_by = group_by if group_by else "day"
try:
from_date = datetime.strptime(from_date, date_format)
@ -81,9 +81,9 @@ def chat_activity():
.order_by(SQL("range"))
)
for group in query:
dates.append(group.range.strftime(date_format))
counts.append(group.count)
for row in query:
dates.append(row.range.strftime(date_format))
counts.append(row.count)
return jsonify({
"date": dates,