mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 12:59:42 -07:00
Fix grouping live tv history
This commit is contained in:
parent
10e62ca42d
commit
4582ff4a56
1 changed files with 15 additions and 9 deletions
|
@ -494,11 +494,13 @@ class ActivityProcessor(object):
|
||||||
prev_watched = None
|
prev_watched = None
|
||||||
|
|
||||||
if session['live']:
|
if session['live']:
|
||||||
# Check if we should group the session, select the last guid from the user
|
# Check if we should group the session, select the last guid from the user within the last day
|
||||||
query = "SELECT session_history.id, session_history_metadata.guid, session_history.reference_id " \
|
query = "SELECT session_history.id, session_history_metadata.guid, session_history.reference_id " \
|
||||||
"FROM session_history " \
|
"FROM session_history " \
|
||||||
"JOIN session_history_metadata ON session_history.id == session_history_metadata.id " \
|
"JOIN session_history_metadata ON session_history.id == session_history_metadata.id " \
|
||||||
"WHERE session_history.id <= ? AND session_history.user_id = ? ORDER BY session_history.id DESC LIMIT 1 "
|
"WHERE session_history.id <= ? AND session_history.user_id = ? " \
|
||||||
|
"AND datetime(session_history.started, 'unixepoch', 'localtime') > datetime('now', '-1 day') " \
|
||||||
|
"ORDER BY session_history.id DESC LIMIT 1 "
|
||||||
|
|
||||||
args = [last_id, session['user_id']]
|
args = [last_id, session['user_id']]
|
||||||
|
|
||||||
|
@ -513,6 +515,8 @@ class ActivityProcessor(object):
|
||||||
'guid': result[0]['guid'],
|
'guid': result[0]['guid'],
|
||||||
'reference_id': result[0]['reference_id']}
|
'reference_id': result[0]['reference_id']}
|
||||||
|
|
||||||
|
prev_watched = False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Check if we should group the session, select the last two rows from the user
|
# Check if we should group the session, select the last two rows from the user
|
||||||
query = "SELECT id, rating_key, view_offset, reference_id FROM session_history " \
|
query = "SELECT id, rating_key, view_offset, reference_id FROM session_history " \
|
||||||
|
@ -550,8 +554,10 @@ class ActivityProcessor(object):
|
||||||
# and new session view offset is greater,
|
# and new session view offset is greater,
|
||||||
# then set the reference_id to the previous row,
|
# then set the reference_id to the previous row,
|
||||||
# else set the reference_id to the new id
|
# else set the reference_id to the new id
|
||||||
if (prev_watched is False and prev_session['view_offset'] <= new_session['view_offset'] or
|
if prev_watched is False and (
|
||||||
session['live'] and prev_session['guid'] == new_session['guid']):
|
not session['live'] and prev_session['view_offset'] <= new_session['view_offset'] or
|
||||||
|
session['live'] and prev_session['guid'] == new_session['guid']
|
||||||
|
):
|
||||||
if metadata:
|
if metadata:
|
||||||
logger.debug("Tautulli ActivityProcessor :: Grouping history for sessionKey %s", session['session_key'])
|
logger.debug("Tautulli ActivityProcessor :: Grouping history for sessionKey %s", session['session_key'])
|
||||||
args = [prev_session['reference_id'], new_session['id']]
|
args = [prev_session['reference_id'], new_session['id']]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue