Don't double notify on fast buffer triggers

If two buffer notifications come in at the same second right at the cusp 
of the notification trigger the difference between the current and last 
trigger would be 0, causing it to send two notifications.

Change the initial value to `None` to prevent this from happening.
This commit is contained in:
Landon Abney 2018-10-11 13:29:21 -07:00
parent fb2362be24
commit 67f70fab90
No known key found for this signature in database
GPG key ID: 4414384AEEE3FB2B

View file

@ -217,14 +217,14 @@ class ActivityHandler(object):
# Update the session state and viewOffset
self.update_db_session()
time_since_last_trigger = 0
time_since_last_trigger = None
if buffer_last_triggered:
logger.debug(u"Tautulli ActivityHandler :: Session %s buffer last triggered at %s." %
(self.get_session_key(), buffer_last_triggered))
time_since_last_trigger = int(time.time()) - int(buffer_last_triggered)
if plexpy.CONFIG.BUFFER_THRESHOLD > 0 and (current_buffer_count >= plexpy.CONFIG.BUFFER_THRESHOLD and \
time_since_last_trigger == 0 or time_since_last_trigger >= plexpy.CONFIG.BUFFER_WAIT):
time_since_last_trigger is None or time_since_last_trigger >= plexpy.CONFIG.BUFFER_WAIT):
ap.set_session_buffer_trigger_time(session_key=self.get_session_key())
# Retrieve the session data from our temp table