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
7cca2dc6
Commit
7cca2dc6
authored
May 21, 2020
by
Vladislav Rykov
Browse files
dashboard recent activity integrated
parent
2271353e
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-37.pyc
View file @
7cca2dc6
No preview for this file type
app/app/dao/misc/.misc.py.swp
View file @
7cca2dc6
No preview for this file type
app/app/dao/misc/__pycache__/misc.cpython-37.pyc
View file @
7cca2dc6
No preview for this file type
app/app/dao/misc/misc.py
View file @
7cca2dc6
...
...
@@ -71,28 +71,31 @@ def get_user_data_count_per_day(cur, username, day=0):
query
=
query
[
0
:
-
10
]
query
+=
') SELECT COUNT(*) FROM t WHERE utc > {} AND utc < {}'
.
format
(
utc_day
,
utc_day
+
24
*
60
*
60
)
print
(
query
)
cur
.
execute
(
query
,
())
return
(
True
,
cur
.
fetchone
())
@
with_psql
def
get_recent_activity
(
cur
,
apps
,
devs
,
n
):
def
get_recent_activity
(
cur
,
username
,
n
=
5
):
apps
=
ad
.
get_list
(
username
)[
1
]
devs
=
[]
for
a
in
apps
:
devs
.
append
(
dd
.
get_list
(
a
[
1
])[
1
])
query
=
''
i
=
0
for
a
in
apps
:
for
d
in
devs
[
i
]:
devs
=
dd
.
get_list
(
a
[
1
])
for
d
in
devs
[
1
]:
query
+=
"""
(SELECT
utc
, appname, devname, data from
(SELECT utc, data from dev_{}_{} limit 5) AS utc,
(SELECT
timedate
, appname, devname, data
, utc
from
(SELECT utc,
timedate,
data from dev_{}_{} limit 5) AS utc,
(SELECT '{}' as appname) AS appname,
(SELECT {} as devname) AS devname)
UNION ALL
"""
.
format
(
a
[
1
],
d
[
1
],
a
[
0
],
d
[
0
])
i
+=
1
(SELECT '{}' as devname) AS devname)
UNION ALL"""
.
format
(
a
[
1
],
d
[
1
],
a
[
0
],
d
[
0
])
query
=
query
[
0
:
-
9
]
query
+=
'ORDER BY utc DESC LIMIT
5'
query
+=
'
ORDER BY utc DESC LIMIT
{}'
.
format
(
n
)
print
(
query
)
cur
.
execute
(
query
,
())
...
...
app/app/templates/new/public/.dashboard.html.swp
View file @
7cca2dc6
No preview for this file type
app/app/templates/new/public/dashboard.html
View file @
7cca2dc6
...
...
@@ -154,75 +154,21 @@
</thead>
<tbody>
<tr>
{% for ra in recent_activity %}
<th
scope=
"row"
>
/argon/
{{ ra[1] }}
</th>
<td>
4,569
{{ ra[2] }}
</td>
<td>
340
{{ ra[0] }}
</td>
<td>
46,53%
</td>
</tr>
<tr>
<th
scope=
"row"
>
/argon/index.html
</th>
<td>
3,985
</td>
<td>
319
</td>
<td>
46,53%
</td>
</tr>
<tr>
<th
scope=
"row"
>
/argon/charts.html
</th>
<td>
3,513
</td>
<td>
294
</td>
<td>
36,49%
</td>
</tr>
<tr>
<th
scope=
"row"
>
/argon/tables.html
</th>
<td>
2,050
</td>
<td>
147
</td>
<td>
50,87%
</td>
</tr>
<tr>
<th
scope=
"row"
>
/argon/profile.html
</th>
<td>
1,795
</td>
<td>
190
</td>
<td>
46,53%
{{ ra[3] }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
...
...
app/app/views.py
View file @
7cca2dc6
...
...
@@ -34,13 +34,16 @@ def index():
total_activity
=
md
.
get_user_data_count
(
session
[
'name'
])[
1
][
0
]
last_activity
=
md
.
get_user_data_count_per_day
(
session
[
'name'
])[
1
][
0
]
print
(
'created_apps'
,
created_apps
)
print
(
'active_devices'
,
active_devices
)
print
(
'total_activity'
,
total_activity
)
print
(
'last_activity'
,
last_activity
)
recent_activity
=
md
.
get_recent_activity
(
session
[
'name'
])[
1
]
#print('created_apps', created_apps)
#print('active_devices', active_devices)
#print('total_activity', total_activity)
#print('last_activity', last_activity)
info
=
[
created_apps
,
active_devices
,
total_activity
,
last_activity
]
return
render_template
(
'new/public/dashboard.html'
,
info
=
info
)
return
render_template
(
'new/public/dashboard.html'
,
info
=
info
,
recent_activity
=
recent_activity
)
#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