mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Write stopped time to database for all events
* To prevent the "long duration" websocket issue for missing stop events
This commit is contained in:
parent
a81dfe83a9
commit
1c8e581cf1
4 changed files with 11 additions and 8 deletions
|
@ -203,7 +203,7 @@ history_table_options = {
|
||||||
"targets": [9],
|
"targets": [9],
|
||||||
"data":"stopped",
|
"data":"stopped",
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (cellData === null) {
|
if (cellData === null || rowData['state'] != null) {
|
||||||
$(td).html('n/a');
|
$(td).html('n/a');
|
||||||
} else {
|
} else {
|
||||||
$(td).html(moment(cellData,"X").format(time_format));
|
$(td).html(moment(cellData,"X").format(time_format));
|
||||||
|
|
|
@ -130,7 +130,8 @@ class ActivityHandler(object):
|
||||||
# Update the session state and viewOffset
|
# Update the session state and viewOffset
|
||||||
ap.set_session_state(session_key=self.get_session_key(),
|
ap.set_session_state(session_key=self.get_session_key(),
|
||||||
state=self.timeline['state'],
|
state=self.timeline['state'],
|
||||||
view_offset=self.timeline['viewOffset'])
|
view_offset=self.timeline['viewOffset'],
|
||||||
|
stopped=int(time.time()))
|
||||||
|
|
||||||
# Retrieve the session data from our temp table
|
# Retrieve the session data from our temp table
|
||||||
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
||||||
|
@ -148,7 +149,8 @@ class ActivityHandler(object):
|
||||||
# Update the session state and viewOffset
|
# Update the session state and viewOffset
|
||||||
ap.set_session_state(session_key=self.get_session_key(),
|
ap.set_session_state(session_key=self.get_session_key(),
|
||||||
state=self.timeline['state'],
|
state=self.timeline['state'],
|
||||||
view_offset=self.timeline['viewOffset'])
|
view_offset=self.timeline['viewOffset'],
|
||||||
|
stopped=int(time.time()))
|
||||||
|
|
||||||
# Retrieve the session data from our temp table
|
# Retrieve the session data from our temp table
|
||||||
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
||||||
|
@ -204,7 +206,8 @@ class ActivityHandler(object):
|
||||||
if this_state == 'playing':
|
if this_state == 'playing':
|
||||||
ap.set_session_state(session_key=self.get_session_key(),
|
ap.set_session_state(session_key=self.get_session_key(),
|
||||||
state=this_state,
|
state=this_state,
|
||||||
view_offset=self.timeline['viewOffset'])
|
view_offset=self.timeline['viewOffset'],
|
||||||
|
stopped=int(time.time()))
|
||||||
# Start our state checks
|
# Start our state checks
|
||||||
if this_state != last_state:
|
if this_state != last_state:
|
||||||
if this_state == 'paused':
|
if this_state == 'paused':
|
||||||
|
|
|
@ -151,9 +151,9 @@ def check_active_sessions(ws_request=False):
|
||||||
|
|
||||||
progress_percent = helpers.get_percent(stream['view_offset'], stream['duration'])
|
progress_percent = helpers.get_percent(stream['view_offset'], stream['duration'])
|
||||||
notify_states = notification_handler.get_notify_state(session=stream)
|
notify_states = notification_handler.get_notify_state(session=stream)
|
||||||
if (session['media_type'] == 'movie' and progress_percent >= plexpy.CONFIG.MOVIE_WATCHED_PERCENT or
|
if (stream['media_type'] == 'movie' and progress_percent >= plexpy.CONFIG.MOVIE_WATCHED_PERCENT or
|
||||||
session['media_type'] == 'episode' and progress_percent >= plexpy.CONFIG.TV_WATCHED_PERCENT or
|
stream['media_type'] == 'episode' and progress_percent >= plexpy.CONFIG.TV_WATCHED_PERCENT or
|
||||||
session['media_type'] == 'track' and progress_percent >= plexpy.CONFIG.MUSIC_WATCHED_PERCENT) \
|
stream['media_type'] == 'track' and progress_percent >= plexpy.CONFIG.MUSIC_WATCHED_PERCENT) \
|
||||||
and not any(d['notify_action'] == 'on_watched' for d in notify_states):
|
and not any(d['notify_action'] == 'on_watched' for d in notify_states):
|
||||||
plexpy.NOTIFY_QUEUE.put({'stream_data': stream, 'notify_action': 'on_watched'})
|
plexpy.NOTIFY_QUEUE.put({'stream_data': stream, 'notify_action': 'on_watched'})
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ class ActivityProcessor(object):
|
||||||
'transcode_audio_channels': session.get('transcode_audio_channels', ''),
|
'transcode_audio_channels': session.get('transcode_audio_channels', ''),
|
||||||
'transcode_width': session.get('stream_video_width', ''),
|
'transcode_width': session.get('stream_video_width', ''),
|
||||||
'transcode_height': session.get('stream_video_height', ''),
|
'transcode_height': session.get('stream_video_height', ''),
|
||||||
'stopped': None
|
'stopped': int(time.time())
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add ip_address back into values
|
# Add ip_address back into values
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue