(feature) Show next scheduled run and backup run type in the UI

Add a scheduler helper that calculates the next due time for a cron-style
schedule expression and surface that value on the dashboard and host detail
pages.

Show the latest run type in host summaries and backup trend tables so
manual and scheduled backups are distinguishable in the Django UI.

Keep the calculation derived from existing ScheduleConfig data without
adding a migration.
This commit is contained in:
2026-05-19 22:57:58 +02:00
parent 9624fb469f
commit 86eee0f916
7 changed files with 55 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ from django.test import SimpleTestCase, TestCase
from pobsync_backend.management.commands.run_pobsync_scheduler import Command
from pobsync_backend.models import HostConfig, ScheduleConfig
from pobsync_backend.scheduler import due_key, is_due
from pobsync_backend.scheduler import due_key, is_due, next_due_after
class SchedulerTests(SimpleTestCase):
@@ -36,6 +36,12 @@ class SchedulerTests(SimpleTestCase):
self.assertEqual(due_key(moment), "202605190215")
def test_next_due_after_returns_next_matching_minute(self) -> None:
moment = datetime(2026, 5, 19, 2, 15, 45, tzinfo=ZoneInfo("UTC"))
self.assertEqual(next_due_after("30 2 * * *", moment), datetime(2026, 5, 19, 2, 30, tzinfo=ZoneInfo("UTC")))
self.assertEqual(next_due_after("15 2 * * *", moment), datetime(2026, 5, 20, 2, 15, tzinfo=ZoneInfo("UTC")))
class SchedulerCommandTests(TestCase):
def test_run_due_executes_schedule_once_per_minute(self) -> None: