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