mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Add previous month comparison
This commit is contained in:
parent
ca0a8d4cda
commit
66e5ed6dd4
3 changed files with 83 additions and 6 deletions
|
@ -147,7 +147,12 @@ activity_by_hour = """SELECT AVG(discord_members_online) online_members_avg,
|
||||||
AVG(discord_members_cv) cv_members_avg,
|
AVG(discord_members_cv) cv_members_avg,
|
||||||
AVG(discord_channels_used) channels_used_avg,
|
AVG(discord_channels_used) channels_used_avg,
|
||||||
AVG(discord_cv) cv_avg,
|
AVG(discord_cv) cv_avg,
|
||||||
extract(hour from timestamp) h
|
extract(hour from timestamp) h
|
||||||
FROM activityreports
|
FROM (
|
||||||
GROUP BY h
|
SELECT *,
|
||||||
|
extract(month from timestamp) month_
|
||||||
|
FROM activityreports
|
||||||
|
) withmonth
|
||||||
|
WHERE withmonth.month_ = :current_month
|
||||||
|
GROUP BY h
|
||||||
ORDER BY h;"""
|
ORDER BY h;"""
|
|
@ -155,7 +155,7 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<h1>
|
<h1>
|
||||||
Media dell'attività per ogni ora
|
Attività per ogni ora nell'ultimo mese
|
||||||
</h1>
|
</h1>
|
||||||
<canvas class="graph members-graph-hour-bucket" id="discord-members-hour-bucket" height="60px"></canvas>
|
<canvas class="graph members-graph-hour-bucket" id="discord-members-hour-bucket" height="60px"></canvas>
|
||||||
<script>
|
<script>
|
||||||
|
@ -213,6 +213,67 @@
|
||||||
},
|
},
|
||||||
"options":{
|
"options":{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<h1>
|
||||||
|
Confronto cv con il mese scorso
|
||||||
|
</h1>
|
||||||
|
<canvas class="graph members-graph-hour-comp" id="discord-members-hour-comp" height="60px"></canvas>
|
||||||
|
<script>
|
||||||
|
new Chart("discord-members-hour-comp",
|
||||||
|
{
|
||||||
|
"type": "line",
|
||||||
|
"data": {
|
||||||
|
"labels": [
|
||||||
|
{% for point in hourly_avg %}
|
||||||
|
"{{ point.h|int }}:00",
|
||||||
|
{% endfor %}
|
||||||
|
],
|
||||||
|
"datasets": [
|
||||||
|
{
|
||||||
|
"label": "Adesso",
|
||||||
|
"borderColor": "#a0ccff",
|
||||||
|
"backgroundColor": "#a0ccff22",
|
||||||
|
"borderWidth": 4,
|
||||||
|
"cubicInterpolationMode": "monotone",
|
||||||
|
"fill": "origin",
|
||||||
|
"data": [
|
||||||
|
{% for point in hourly_avg %}
|
||||||
|
{{ point.cv_members_avg }},
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Il mese scorso",
|
||||||
|
"borderColor": "#d3a1ff",
|
||||||
|
"backgroundColor": "#d3a1ff11",
|
||||||
|
"borderWidth": 1,
|
||||||
|
"cubicInterpolationMode": "monotone",
|
||||||
|
"fill": "origin",
|
||||||
|
"data": [
|
||||||
|
{% for point in hourly_comp %}
|
||||||
|
{{ point.cv_members_avg }},
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Il mese prima",
|
||||||
|
"borderColor": "#ffa3d0",
|
||||||
|
"backgroundColor": "#ffa3d011",
|
||||||
|
"borderWidth": 1,
|
||||||
|
"cubicInterpolationMode": "monotone",
|
||||||
|
"fill": "origin",
|
||||||
|
"data": [
|
||||||
|
{% for point in hourly_before %}
|
||||||
|
{{ point.cv_members_avg }},
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"options":{
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
15
webserver.py
15
webserver.py
|
@ -365,8 +365,19 @@ def page_music_individual(discord_id: str):
|
||||||
@app.route("/activity")
|
@app.route("/activity")
|
||||||
def page_activity():
|
def page_activity():
|
||||||
reports = list(fl_g.session.query(db.ActivityReport).order_by(db.ActivityReport.timestamp.desc()).limit(192).all())
|
reports = list(fl_g.session.query(db.ActivityReport).order_by(db.ActivityReport.timestamp.desc()).limit(192).all())
|
||||||
hourly_avg = list(fl_g.session.execute(sql_queries.activity_by_hour))
|
hourly_avg = list(fl_g.session.execute(sql_queries.activity_by_hour, {"current_month": datetime.datetime.now().month}))
|
||||||
return render_template("activity.html", activityreports=list(reversed(reports)), hourly_avg=hourly_avg)
|
previous_month = datetime.datetime.now().month - 1
|
||||||
|
if previous_month == 0:
|
||||||
|
previous_month = 12
|
||||||
|
hourly_comp = list(fl_g.session.execute(sql_queries.activity_by_hour, {"current_month": previous_month}))
|
||||||
|
even_before_month = previous_month - 1
|
||||||
|
if even_before_month == 0:
|
||||||
|
even_before_month = 12
|
||||||
|
hourly_before = list(fl_g.session.execute(sql_queries.activity_by_hour, {"current_month": even_before_month}))
|
||||||
|
return render_template("activity.html", activityreports=list(reversed(reports)),
|
||||||
|
hourly_avg=hourly_avg,
|
||||||
|
hourly_comp=hourly_comp,
|
||||||
|
hourly_before=hourly_before)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/ses/identify")
|
@app.route("/ses/identify")
|
||||||
|
|
Loading…
Reference in a new issue