Fix watched status to use watched percent specified in settings

This commit is contained in:
Jonathan Wong 2015-09-16 13:30:05 -07:00
parent adc808ac9f
commit 626e7fdf82
3 changed files with 15 additions and 6 deletions

View file

@ -201,11 +201,11 @@ history_table_options = {
},
{
"targets": [10],
"data":"percent_complete",
"data": "watched_status",
"render": function (data, type, full) {
if (data > 80) {
if (data == 1) {
return '<span class="watched-tooltip" data-toggle="tooltip" title="Watched"><i class="fa fa-lg fa-circle"></i></span>'
} else if (data > 40) {
} else if (data == 0.5) {
return '<span class="watched-tooltip" data-toggle="tooltip" title="Partial"><i class="fa fa-lg fa-adjust fa-rotate-180"></i></span>'
} else {
return '<span class="watched-tooltip" data-toggle="tooltip" title="Unwatched"><i class="fa fa-lg fa-circle-o"></i></span>'

View file

@ -26,7 +26,7 @@ class DataFactory(object):
def __init__(self):
pass
def get_history(self, kwargs=None, custom_where=None, grouping=0):
def get_history(self, kwargs=None, custom_where=None, grouping=0, watched_percent=85):
data_tables = datatables.DataTables()
group_by = ['session_history.reference_id'] if grouping else ['session_history.id']
@ -95,6 +95,13 @@ class DataFactory(object):
else:
thumb = item["thumb"]
if item['percent_complete'] >= watched_percent:
watched_status = 1
elif item['percent_complete'] >= watched_percent/2:
watched_status = 0.5
else:
watched_status = 0
row = {"reference_id": item["reference_id"],
"id": item["id"],
"date": item["date"],
@ -118,7 +125,7 @@ class DataFactory(object):
"parent_media_index": item["parent_media_index"],
"thumb": thumb,
"video_decision": item["video_decision"],
"percent_complete": item["percent_complete"],
"watched_status": watched_status,
"group_count": item["group_count"]
}

View file

@ -576,6 +576,8 @@ class WebInterface(object):
else:
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
watched_percent = plexpy.CONFIG.NOTIFY_WATCHED_PERCENT
custom_where=[]
if user_id:
custom_where = [['user_id', user_id]]
@ -598,7 +600,7 @@ class WebInterface(object):
custom_where = [['session_history.reference_id', reference_id]]
data_factory = datafactory.DataFactory()
history = data_factory.get_history(kwargs=kwargs, custom_where=custom_where, grouping=grouping)
history = data_factory.get_history(kwargs=kwargs, custom_where=custom_where, grouping=grouping, watched_percent=watched_percent)
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps(history)