-
Notifications
You must be signed in to change notification settings - Fork 0
/
Engagement.py
101 lines (81 loc) · 3.46 KB
/
Engagement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import streamlit as st
import settings
from rich import print
import metrics
from millify import prettify
import ui_components as uic
import ui_widgets as ui
import users
st.set_page_config(layout="wide")
st.title("Curious Learning Dashboard")
st.subheader("Page Purpose: Explore the user statistics")
ui.display_definitions_table("Definitions",ui.level_definitions)
ui.display_definitions_table("Data Notes",ui.data_notes)
settings.initialize()
settings.init_user_list()
ui.colorize_multiselect_options()
selected_date, option = ui.calendar_selector()
daterange = ui.convert_date_to_range(selected_date, option)
languages = users.get_language_list()
language = ui.single_selector(
languages, title="Select a language", placement="side", key="e-1"
)
countries_list = users.get_country_list()
countries_list = ui.multi_select_all(
countries_list, title="Country Selection", key="e-2"
)
app = ui.app_selector()
# In the case of datepicker, don't do anything until both start and end dates are picked
if len(daterange) == 2 and len(countries_list) > 0:
date_start = daterange[0].strftime("%Y-%m-%d")
date_end = daterange[1].strftime("%Y-%m-%d")
st.subheader("General Engagement")
st.markdown("**Selected Range:**")
st.text(date_start + " to " + date_end)
col1, col2, col3 = st.columns(3)
total = metrics.get_totals_by_metric(
daterange, countries_list, stat="LR", app=app, language=language
)
col1.metric(label="Learners Reached", value=prettify(int(total)))
total = metrics.get_totals_by_metric(
daterange, countries_list, "LA", app=app, language=language
)
col2.metric(label="Learners Acquired", value=prettify(int(total)))
total = metrics.get_totals_by_metric(
daterange, countries_list, "RA", app=app, language=language
)
col3.metric(label="Readers Acquired", value=prettify(int(total)))
total = metrics.get_totals_by_metric(
daterange, countries_list, "GC", app=app, language=language
)
col1.metric(label="Games Completed", value=prettify(int(total)))
total = metrics.get_GPP_avg(daterange, countries_list, app=app, language=language)
col2.metric(label="Game Progress Percent", value=f"{total:.2f}%")
total = metrics.get_GC_avg(daterange, countries_list, app=app, language=language)
col3.metric(label="Game Completion Avg", value=f"{total:.2f}%")
st.divider()
st.subheader("Levels reached per language")
uic.levels_line_chart(daterange, countries_list, app=app, language=language)
st.divider()
st.subheader("Engagement across the world")
option = ui.stats_radio_selector()
uic.stats_by_country_map(
daterange, countries_list, app=app, language=language, option=option
)
st.divider()
st.subheader("Top 10's")
c1, c2, c3,c4 = st.columns(4)
with c1:
option = st.radio("Select a statistic", ("LR", "LA", "RA"), index=0, horizontal=True,key="e-3")
with c2:
display_category = st.radio(
"Display by", ("Country", "Language"), index=0, horizontal=True, key="e-4"
)
uic.top_LR_LC_bar_chart(
daterange, countries_list, option, app=app, language=language,display_category=display_category
)
c1, c2 = st.columns(2)
with c1:
uic.top_gpp_bar_chart(daterange, countries_list, app=app, language=language,display_category=display_category)
with c2:
uic.top_gca_bar_chart(daterange, countries_list, app=app, language=language,display_category=display_category)