(feature) show latest snapshot on the Django dashboard
Add latest snapshot context to each dashboard host row so imported legacy snapshots are visible without opening every host page. Link the latest snapshot directly to its detail page and show its kind and status beside the host snapshot count. Cover the dashboard latest-snapshot selection with a view test.
This commit is contained in:
@@ -20,12 +20,18 @@ from .snapshot_discovery import discover_snapshots, inspect_snapshot_discovery
|
||||
|
||||
@staff_member_required
|
||||
def dashboard(request):
|
||||
host_qs = (
|
||||
hosts = list(
|
||||
HostConfig.objects.annotate(snapshot_count=Count("snapshots", distinct=True), run_count=Count("runs", distinct=True))
|
||||
.order_by("host")
|
||||
)
|
||||
for host_config in hosts:
|
||||
host_config.latest_snapshot = (
|
||||
host_config.snapshots.select_related("base")
|
||||
.order_by("-started_at", "-discovered_at", "-id")
|
||||
.first()
|
||||
)
|
||||
context = {
|
||||
"hosts": host_qs,
|
||||
"hosts": hosts,
|
||||
"global_config": GlobalConfig.objects.filter(name="default").first(),
|
||||
"latest_runs": BackupRun.objects.select_related("host", "snapshot").order_by("-created_at")[:10],
|
||||
"counts": {
|
||||
|
||||
Reference in New Issue
Block a user