Modify /chat_activity
This commit is contained in:
parent
add2351bee
commit
6baefaeac1
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue