Show all users in Users table even if they don't have any history.

This commit is contained in:
Tim 2015-08-14 01:05:35 +02:00
parent e8e5a0b5ff
commit ad12a85c6c
3 changed files with 29 additions and 20 deletions

View file

@ -27,6 +27,7 @@ users_list_table_options = {
}
},
"orderable": false,
"searchable": false,
"className": "users-poster-face",
"width": "40px"
},
@ -47,21 +48,33 @@ users_list_table_options = {
},
{
"targets": [2],
"data": "started",
"data": "last_seen",
"render": function ( data, type, full ) {
return moment(data, "X").fromNow();
if (data) {
return moment(data, "X").fromNow();
} else {
return "never";
}
},
"searchable": false,
"className": "hidden-xs",
},
{
"targets": [3],
"data": "ip_address",
"searchable": false,
"render": function ( data, type, full ) {
if (data) {
return data;
} else {
return "n/a";
}
},
"className": "hidden-xs",
},
{
"targets": [4],
"data": "plays"
"data": "plays",
"searchable": false
}
],

View file

@ -9,7 +9,7 @@
<div class='container-fluid'>
<div class='table-card-header'>
<div class="header-bar">
<span><i class="fa fa-group"></i> Active Users</span>
<span><i class="fa fa-group"></i> All Users</span>
</div>
<div class="button-bar">
<button class="btn btn-dark" id="refresh-users-list"><i class="fa fa-refresh"></i> Refresh users</button>

View file

@ -29,26 +29,23 @@ class DataFactory(object):
def get_user_list(self, kwargs=None):
data_tables = datatables.DataTables()
columns = ['session_history.id',
columns = ['users.user_id as user_id',
'users.thumb as thumb',
'(case when users.friendly_name is null then session_history.user else \
'(case when users.friendly_name is null then users.username else \
users.friendly_name end) as friendly_name',
'session_history.started',
'session_history.ip_address',
'MAX(session_history.started) as last_seen',
'session_history.ip_address as ip_address',
'COUNT(session_history.id) as plays',
'session_history.user',
'session_history.user_id',
'(case when typeof(session_history.user_id) = "integer" \
then session_history.user_id else -1 end) as grp_id',
'users.username as user'
]
try:
query = data_tables.ssp_query(table_name='session_history',
query = data_tables.ssp_query(table_name='users',
columns=columns,
custom_where=[],
group_by=['grp_id'],
group_by=['users.user_id'],
join_types=['LEFT OUTER JOIN'],
join_tables=['users'],
join_evals=[['grp_id', 'users.user_id']],
join_tables=['session_history'],
join_evals=[['session_history.user_id', 'users.user_id']],
kwargs=kwargs)
except:
logger.warn("Unable to execute database query.")
@ -67,9 +64,8 @@ class DataFactory(object):
else:
user_thumb = item['thumb']
row = {"id": item['id'],
"plays": item['plays'],
"started": item['started'],
row = {"plays": item['plays'],
"last_seen": item['last_seen'],
"friendly_name": item["friendly_name"],
"ip_address": item["ip_address"],
"thumb": user_thumb,