|
@@ -29,18 +29,31 @@ def _retention_label(job):
|
|
|
return "—"
|
|
return "—"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def _job_detail(job):
|
|
|
|
|
+ """Détail affiché à côté du nom du job pour distinguer des jobs homonymes
|
|
|
|
|
+ (ex: instances multiples d'une même app YunoHost, toutes nommées pareil)."""
|
|
|
|
|
+ if job.type not in ("ynh_app", "custom_dir", "mysql", "postgresql"):
|
|
|
|
|
+ return ""
|
|
|
|
|
+ cfg = json.loads(job.config_json or "{}")
|
|
|
|
|
+ if job.type == "ynh_app":
|
|
|
|
|
+ return cfg.get("app_id", "")
|
|
|
|
|
+ if job.type == "custom_dir":
|
|
|
|
|
+ return cfg.get("source_path", "")
|
|
|
|
|
+ return cfg.get("database", "")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def _group_archives(archive_list, jobs, instance):
|
|
def _group_archives(archive_list, jobs, instance):
|
|
|
"""
|
|
"""
|
|
|
archive_list : [{"name": "jerry_nextcloud_20260716", "size_bytes": N}]
|
|
archive_list : [{"name": "jerry_nextcloud_20260716", "size_bytes": N}]
|
|
|
Retourne (groups, orphaned) où chaque group est associé à un job.
|
|
Retourne (groups, orphaned) où chaque group est associé à un job.
|
|
|
"""
|
|
"""
|
|
|
- from retention import _job_archive_prefix, _extract_date
|
|
|
|
|
|
|
+ from retention import _job_archive_prefix, _matches_job_prefix, _extract_date
|
|
|
|
|
|
|
|
used = set()
|
|
used = set()
|
|
|
groups = []
|
|
groups = []
|
|
|
for job in jobs:
|
|
for job in jobs:
|
|
|
prefix = _job_archive_prefix(job, instance)
|
|
prefix = _job_archive_prefix(job, instance)
|
|
|
- matching = [a for a in archive_list if a["name"].startswith(prefix)]
|
|
|
|
|
|
|
+ matching = [a for a in archive_list if _matches_job_prefix(a["name"], prefix)]
|
|
|
matching.sort(key=lambda a: _extract_date(a["name"] + ".tar"))
|
|
matching.sort(key=lambda a: _extract_date(a["name"] + ".tar"))
|
|
|
for a in matching:
|
|
for a in matching:
|
|
|
used.add(a["name"])
|
|
used.add(a["name"])
|
|
@@ -50,6 +63,7 @@ def _group_archives(archive_list, jobs, instance):
|
|
|
groups.append({
|
|
groups.append({
|
|
|
"job": job,
|
|
"job": job,
|
|
|
"retention_label": _retention_label(job),
|
|
"retention_label": _retention_label(job),
|
|
|
|
|
+ "detail": _job_detail(job),
|
|
|
"archives": matching,
|
|
"archives": matching,
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -191,6 +205,7 @@ def overview():
|
|
|
jobs_view.append({
|
|
jobs_view.append({
|
|
|
"job": job,
|
|
"job": job,
|
|
|
"retention_label": _retention_label(job),
|
|
"retention_label": _retention_label(job),
|
|
|
|
|
+ "detail": _job_detail(job),
|
|
|
"locations": jlocs,
|
|
"locations": jlocs,
|
|
|
})
|
|
})
|
|
|
|
|
|