Fix loading of scheduled tasks when tasks are disabled

This commit is contained in:
JonnyWong16 2024-06-06 21:39:33 -07:00
commit f1d44c051d
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 3 additions and 6 deletions

View file

@ -13,8 +13,6 @@ DOCUMENTATION :: END
import datetime import datetime
import plexpy import plexpy
from plexpy import common, helpers from plexpy import common, helpers
scheduled_jobs = [j.id for j in plexpy.SCHED.get_jobs()]
%> %>
<table class="config-scheduler-table small-muted"> <table class="config-scheduler-table small-muted">
@ -29,16 +27,15 @@ DOCUMENTATION :: END
</thead> </thead>
<tbody> <tbody>
% for job, job_type in common.SCHEDULER_LIST.items(): % for job, job_type in common.SCHEDULER_LIST.items():
% if job in scheduled_jobs:
<% <%
sched_job = plexpy.SCHED.get_job(job) sched_job = plexpy.SCHED.get_job(job)
now = datetime.datetime.now(sched_job.next_run_time.tzinfo)
%> %>
% if sched_job:
<tr> <tr>
<td>${sched_job.id}</td> <td>${sched_job.id}</td>
<td><i class="fa fa-sm fa-fw fa-check"></i> Active</td> <td><i class="fa fa-sm fa-fw fa-check"></i> Active</td>
<td>${helpers.format_timedelta_Hms(sched_job.trigger.interval)}</td> <td>${helpers.format_timedelta_Hms(sched_job.trigger.interval)}</td>
<td>${helpers.format_timedelta_Hms(sched_job.next_run_time - now)}</td> <td>${helpers.format_timedelta_Hms(sched_job.next_run_time - datetime.datetime.now(sched_job.next_run_time.tzinfo))}</td>
<td>${sched_job.next_run_time.astimezone(plexpy.SYS_TIMEZONE).strftime('%Y-%m-%d %H:%M:%S')}</td> <td>${sched_job.next_run_time.astimezone(plexpy.SYS_TIMEZONE).strftime('%Y-%m-%d %H:%M:%S')}</td>
</tr> </tr>
% elif job_type == 'websocket' and plexpy.WS_CONNECTED: % elif job_type == 'websocket' and plexpy.WS_CONNECTED:

View file

@ -237,7 +237,7 @@ EXTRA_TYPES = {
} }
SCHEDULER_LIST = [ SCHEDULER_LIST = [
('Check GitHub for updates', 'websocket'), ('Check GitHub for updates', 'scheduled'),
('Check for server response', 'websocket'), ('Check for server response', 'websocket'),
('Check for active sessions', 'websocket'), ('Check for active sessions', 'websocket'),
('Check for recently added items', 'websocket'), ('Check for recently added items', 'websocket'),