Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladislav Rykov
THSO.server
Commits
eae6de73
Commit
eae6de73
authored
May 22, 2020
by
Vladislav Rykov
Browse files
dashboard completely integrated
parent
b54e43a4
Changes
8
Hide whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-37.pyc
View file @
eae6de73
No preview for this file type
app/app/dao/misc/.misc.py.swp
View file @
eae6de73
No preview for this file type
app/app/dao/misc/__pycache__/misc.cpython-37.pyc
View file @
eae6de73
No preview for this file type
app/app/dao/misc/misc.py
View file @
eae6de73
...
...
@@ -104,7 +104,6 @@ def get_user_data_count_per_day(cur, username, day=0):
return
(
True
,
cur
.
fetchone
())
@
with_psql
def
get_user_data_count_per_day_period
(
cur
,
username
,
period
):
apps
=
ad
.
get_list
(
username
)[
1
]
...
...
@@ -113,7 +112,7 @@ def get_user_data_count_per_day_period(cur, username, period):
for
a
in
apps
:
devs
.
append
(
dd
.
get_list
(
a
[
1
])[
1
])
utc_
day
=
utc_roundday
(
day
)
utc_
hour
=
[
utc_roundday
(
x
)
for
x
in
range
(
period
,
-
1
,
-
1
)]
query
=
'WITH t AS ('
i
=
0
...
...
@@ -122,11 +121,15 @@ def get_user_data_count_per_day_period(cur, username, period):
query
+=
'SELECT utc FROM dev_{}_{} UNION ALL '
.
format
(
a
[
1
],
d
[
1
])
i
+=
1
query
=
query
[
0
:
-
10
]
query
+=
') SELECT COUNT(*) FROM t WHERE utc > {} AND utc < {}'
.
format
(
utc_day
,
utc_day
+
24
*
60
*
60
)
query
+=
') SELECT * FROM ('
for
uh
in
utc_hour
:
query
+=
' SELECT COUNT(*) FROM t WHERE utc > {} AND utc < {} UNION ALL'
.
format
(
uh
,
uh
+
24
*
60
*
60
)
query
=
query
[
0
:
-
9
]
query
+=
') w'
cur
.
execute
(
query
,
())
return
(
True
,
cur
.
fetch
one
())
return
(
True
,
cur
.
fetch
all
())
@
with_psql
...
...
app/app/helpers/__pycache__/misc.cpython-37.pyc
View file @
eae6de73
No preview for this file type
app/app/helpers/misc.py
View file @
eae6de73
...
...
@@ -143,3 +143,10 @@ def utc_hour(hour_offset):
def
utc_weekday
(
day_offset
=
0
):
d
=
{
0
:
'Mo'
,
1
:
'Tu'
,
2
:
'We'
,
3
:
'Th'
,
4
:
'Fr'
,
5
:
'Sa'
,
6
:
'Su'
}
return
(
d
[((
datetime
.
utcnow
().
weekday
()
-
day_offset
)
%
7
)])
def
local_hour
(
hour_offset
):
return
((
datetime
.
now
().
hour
-
hour_offset
)
%
24
)
def
local_weekday
(
day_offset
=
0
):
d
=
{
0
:
'Mo'
,
1
:
'Tu'
,
2
:
'We'
,
3
:
'Th'
,
4
:
'Fr'
,
5
:
'Sa'
,
6
:
'Su'
}
return
(
d
[((
datetime
.
now
().
weekday
()
-
day_offset
)
%
7
)])
app/app/templates/new/public/dashboard.html
View file @
eae6de73
...
...
@@ -223,11 +223,11 @@
},
data
:
{
labels
:
[
"
Sun
"
,
"
Mon
"
,
"
Tue
"
,
"
Wen
"
,
"
Thu
"
,
"
Fri
"
,
"
Sat
"
]
,
labels
:
{{
week_chart
[
0
]
|
safe
}}
,
datasets
:
[
{
label
:
"
Sales
"
,
data
:
[
25
,
20
,
30
,
22
,
36
,
29
,
15
]
data
:
{{
week_chart
[
1
]
}}
}]
}
}),
e
.
data
(
"
chart
"
,
a
))
...
...
@@ -249,13 +249,6 @@
lineWidth
:
1
,
color
:
Charts
.
colors
.
gray
[
900
],
zeroLineColor
:
Charts
.
colors
.
gray
[
900
]
},
ticks
:
{
callback
:
function
(
e
)
{
if
(
!
(
e
%
10
))
return
/*"$"*/
+
e
}
}
}]
},
...
...
@@ -268,18 +261,18 @@
var
t
=
a
.
datasets
[
e
.
datasetIndex
].
label
||
""
,
o
=
e
.
yLabel
,
n
=
""
;
return
1
<
a
.
datasets
.
length
&&
(
n
+=
'
<span class="popover-body-label mr-auto">
'
+
t
+
"
</span>
"
),
n
+=
'
<span class="popover-body-value">
$
'
+
o
+
"
k
</span>
"
return
1
<
a
.
datasets
.
length
&&
(
n
+=
'
<span class="popover-body-label mr-auto">
'
+
t
+
"
</span>
"
),
n
+=
'
<span class="popover-body-value">
'
+
o
+
"
</span>
"
}
}
}
},
data
:
{
labels
:
{{
day_chart
.
keys
()
|
list
}},
labels
:
{{
day_chart
[
0
]
}},
datasets
:
[
{
label
:
"
Performance
"
,
data
:
{{
day_chart
.
values
()
|
list
}}
data
:
{{
day_chart
[
1
]
}}
}]
}
}),
e
.
data
(
"
chart
"
,
a
))
...
...
app/app/views.py
View file @
eae6de73
...
...
@@ -41,14 +41,17 @@ def index():
#print('last_activity', last_activity)
info
=
[
created_apps
,
active_devices
,
total_activity
,
last_activity
]
r
=
md
.
get_user_data_count_per_hour_period
(
session
[
'name'
],
12
)[
1
]
r
=
[
x
[
0
]
for
x
in
r
]
day_chart
=
{}
for
i
in
range
(
12
,
-
1
,
-
1
):
day_chart
[
misc
.
utc_hour
(
i
)]
=
r
[
i
]
day_chart_values
=
md
.
get_user_data_count_per_hour_period
(
session
[
'name'
],
11
)[
1
]
day_chart_values
=
[
x
[
0
]
for
x
in
day_chart_values
]
day_chart_labels
=
[
misc
.
local_hour
(
x
)
for
x
in
range
(
11
,
-
1
,
-
1
)]
day_chart
=
[
day_chart_labels
,
day_chart_values
]
week_chart_values
=
md
.
get_user_data_count_per_day_period
(
session
[
'name'
],
6
)[
1
]
week_chart_values
=
[
x
[
0
]
for
x
in
week_chart_values
]
week_chart_labels
=
[
misc
.
local_weekday
(
x
)
for
x
in
range
(
6
,
-
1
,
-
1
)]
week_chart
=
[
week_chart_labels
,
week_chart_values
]
return
render_template
(
'new/public/dashboard.html'
,
info
=
info
,
recent_activity
=
recent_activity
,
day_chart
=
day_chart
)
return
render_template
(
'new/public/dashboard.html'
,
info
=
info
,
recent_activity
=
recent_activity
,
day_chart
=
day_chart
,
week_chart
=
week_chart
)
#apps = ad.get_list(session['name'])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment