1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2025-03-11 22:53:33 +00:00

Show date of next backup. By @tal66 (#1319)

This commit is contained in:
tal66 2022-05-29 16:44:17 +03:00 committed by GitHub
parent e0911a61f4
commit 422ca7f418
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -333,24 +333,28 @@ class VortaScheduler(QtCore.QObject):
self.set_timer_for_profile(profile.id) self.set_timer_for_profile(profile.id)
def next_job(self): def next_job(self):
next_job = now = dt.now() now = dt.now()
next_profile = None
for profile_id, timer in self.timers.items():
if timer['type'] != ScheduleStatusType.SCHEDULED:
continue
if next_job == now and timer['dt'] > next_job and timer['qtt'].isActive(): def is_scheduled(timer):
next_job = timer['dt'] return (
next_profile = profile_id timer["type"] == ScheduleStatusType.SCHEDULED
elif next_job > now and timer['dt'] < next_job and timer['qtt'].isActive(): and timer["qtt"].isActive()
next_job = timer['dt'] and timer["dt"] >= now
next_profile = profile_id )
if next_profile is not None: scheduled = {profile_id: timer for profile_id, timer in self.timers.items() if is_scheduled(timer)}
profile = BackupProfileModel.get_or_none(id=next_profile) if len(scheduled) == 0:
return f"{next_job.strftime('%H:%M')} ({profile.name})" return self.tr("None scheduled")
else:
return self.tr('None scheduled') closest_job = min(scheduled.items(), key=lambda item: item[1]["dt"])
profile_id, timer = closest_job
time = timer["dt"]
profile = BackupProfileModel.get_or_none(id=profile_id)
time_format = "%H:%M"
if time - now > timedelta(days=1):
time_format = "%b %d, %H:%M"
return f"{time.strftime(time_format)} ({profile.name})"
def next_job_for_profile(self, profile_id: int) -> ScheduleStatus: def next_job_for_profile(self, profile_id: int) -> ScheduleStatus:
job = self.timers.get(profile_id) job = self.timers.get(profile_id)