mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 21:51:14 -07:00
Fix grouping or new plays not previously in history
This commit is contained in:
parent
7292f25eb9
commit
917d19db85
1 changed files with 9 additions and 6 deletions
|
@ -275,6 +275,7 @@ class ActivityProcessor(object):
|
||||||
result = self.db.select(query=query, args=args)
|
result = self.db.select(query=query, args=args)
|
||||||
|
|
||||||
new_session = prev_session = None
|
new_session = prev_session = None
|
||||||
|
prev_progress_percent = media_watched_percent = 0
|
||||||
# Get the last insert row id
|
# Get the last insert row id
|
||||||
last_id = self.db.last_insert_id()
|
last_id = self.db.last_insert_id()
|
||||||
|
|
||||||
|
@ -291,12 +292,14 @@ class ActivityProcessor(object):
|
||||||
'user_id': result[1]['user_id'],
|
'user_id': result[1]['user_id'],
|
||||||
'reference_id': result[1]['reference_id']}
|
'reference_id': result[1]['reference_id']}
|
||||||
|
|
||||||
query = 'UPDATE session_history SET reference_id = ? WHERE id = ? '
|
|
||||||
watched_percent = {'movie': plexpy.CONFIG.MOVIE_WATCHED_PERCENT,
|
watched_percent = {'movie': plexpy.CONFIG.MOVIE_WATCHED_PERCENT,
|
||||||
'episode': plexpy.CONFIG.TV_WATCHED_PERCENT,
|
'episode': plexpy.CONFIG.TV_WATCHED_PERCENT,
|
||||||
'track': plexpy.CONFIG.MUSIC_WATCHED_PERCENT
|
'track': plexpy.CONFIG.MUSIC_WATCHED_PERCENT
|
||||||
}
|
}
|
||||||
prev_progress_percent = helpers.get_percent(prev_session['view_offset'], session['duration'])
|
prev_progress_percent = helpers.get_percent(prev_session['view_offset'], session['duration'])
|
||||||
|
media_watched_percent = watched_percent.get(session['media_type'], 0)
|
||||||
|
|
||||||
|
query = 'UPDATE session_history SET reference_id = ? WHERE id = ? '
|
||||||
|
|
||||||
# If previous session view offset less than watched percent,
|
# If previous session view offset less than watched percent,
|
||||||
# and new session view offset is greater,
|
# and new session view offset is greater,
|
||||||
|
@ -304,7 +307,7 @@ class ActivityProcessor(object):
|
||||||
# else set the reference_id to the new id
|
# else set the reference_id to the new id
|
||||||
if prev_session is None and new_session is None:
|
if prev_session is None and new_session is None:
|
||||||
args = [last_id, last_id]
|
args = [last_id, last_id]
|
||||||
elif prev_progress_percent < watched_percent.get(session['media_type'], 0) and \
|
elif prev_progress_percent < media_watched_percent and \
|
||||||
prev_session['view_offset'] <= new_session['view_offset']:
|
prev_session['view_offset'] <= new_session['view_offset']:
|
||||||
args = [prev_session['reference_id'], new_session['id']]
|
args = [prev_session['reference_id'], new_session['id']]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue