mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 12:59:42 -07:00
Group recently watched tracks together by album
* Also group identical movie or episode
This commit is contained in:
parent
5ec9e41244
commit
5126c39c26
1 changed files with 31 additions and 20 deletions
|
@ -524,24 +524,35 @@ class DataFactory(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if user_id:
|
if user_id:
|
||||||
query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, parent_title, ' \
|
query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, session_history.parent_rating_key, ' \
|
||||||
'grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, year, started, user ' \
|
'title, parent_title, grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, ' \
|
||||||
|
'year, started, user ' \
|
||||||
'FROM session_history_metadata ' \
|
'FROM session_history_metadata ' \
|
||||||
'JOIN session_history ON session_history_metadata.id = session_history.id ' \
|
'JOIN session_history ON session_history_metadata.id = session_history.id ' \
|
||||||
'WHERE user_id = ? ORDER BY started DESC LIMIT ?'
|
'WHERE user_id = ? ' \
|
||||||
|
'GROUP BY (CASE WHEN session_history.media_type = "track" THEN session_history.parent_rating_key ' \
|
||||||
|
' ELSE session_history.rating_key END) ' \
|
||||||
|
'ORDER BY started DESC LIMIT ?'
|
||||||
result = monitor_db.select(query, args=[user_id, limit])
|
result = monitor_db.select(query, args=[user_id, limit])
|
||||||
elif user:
|
elif user:
|
||||||
query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, parent_title, ' \
|
query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, session_history.parent_rating_key, ' \
|
||||||
'grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, year, started, user ' \
|
'title, parent_title, grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, ' \
|
||||||
|
'year, started, user ' \
|
||||||
'FROM session_history_metadata ' \
|
'FROM session_history_metadata ' \
|
||||||
'JOIN session_history ON session_history_metadata.id = session_history.id ' \
|
'JOIN session_history ON session_history_metadata.id = session_history.id ' \
|
||||||
'WHERE user = ? ORDER BY started DESC LIMIT ?'
|
'WHERE user = ? ' \
|
||||||
|
'GROUP BY (CASE WHEN session_history.media_type = "track" THEN session_history.parent_rating_key ' \
|
||||||
|
' ELSE session_history.rating_key END) ' \
|
||||||
|
'ORDER BY started DESC LIMIT ?'
|
||||||
result = monitor_db.select(query, args=[user, limit])
|
result = monitor_db.select(query, args=[user, limit])
|
||||||
else:
|
else:
|
||||||
query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, title, parent_title, ' \
|
query = 'SELECT session_history.id, session_history.media_type, session_history.rating_key, session_history.parent_rating_key, ' \
|
||||||
'grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, year, started, user ' \
|
'title, parent_title, grandparent_title, thumb, parent_thumb, grandparent_thumb, media_index, parent_media_index, ' \
|
||||||
|
'year, started, user ' \
|
||||||
'FROM session_history_metadata ' \
|
'FROM session_history_metadata ' \
|
||||||
'JOIN session_history ON session_history_metadata.id = session_history.id ' \
|
'JOIN session_history ON session_history_metadata.id = session_history.id ' \
|
||||||
|
'GROUP BY (CASE WHEN session_history.media_type = "track" THEN session_history.parent_rating_key ' \
|
||||||
|
' ELSE session_history.rating_key END) ' \
|
||||||
'ORDER BY started DESC LIMIT ?'
|
'ORDER BY started DESC LIMIT ?'
|
||||||
result = monitor_db.select(query, args=[limit])
|
result = monitor_db.select(query, args=[limit])
|
||||||
except:
|
except:
|
||||||
|
@ -549,25 +560,25 @@ class DataFactory(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for row in result:
|
for row in result:
|
||||||
if row[1] == 'episode' and row[7]:
|
if row[1] == 'episode' and row[8]:
|
||||||
thumb = row[7]
|
|
||||||
elif row[1] == 'episode':
|
|
||||||
thumb = row[8]
|
thumb = row[8]
|
||||||
|
elif row[1] == 'episode':
|
||||||
|
thumb = row[9]
|
||||||
else:
|
else:
|
||||||
thumb = row[6]
|
thumb = row[7]
|
||||||
|
|
||||||
recent_output = {'row_id': row[0],
|
recent_output = {'row_id': row[0],
|
||||||
'type': row[1],
|
'type': row[1],
|
||||||
'rating_key': row[2],
|
'rating_key': row[2],
|
||||||
'title': row[3],
|
'title': row[4],
|
||||||
'parent_title': row[4],
|
'parent_title': row[5],
|
||||||
'grandparent_title': row[5],
|
'grandparent_title': row[6],
|
||||||
'thumb': thumb,
|
'thumb': thumb,
|
||||||
'index': row[9],
|
'index': row[10],
|
||||||
'parent_index': row[10],
|
'parent_index': row[11],
|
||||||
'year': row[11],
|
'year': row[12],
|
||||||
'time': row[12],
|
'time': row[13],
|
||||||
'user': row[13]
|
'user': row[14]
|
||||||
}
|
}
|
||||||
recently_watched.append(recent_output)
|
recently_watched.append(recent_output)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue