Files
TallerCiCd/backend/app/services/builds.py
2025-12-15 12:52:10 +01:00

23 lines
619 B
Python

import json
from pathlib import Path
from typing import Dict, List
DATA_DIR = Path(__file__).resolve().parent.parent / "data"
def _load_json(filename: str) -> Dict:
path = DATA_DIR / filename
with open(path, encoding="utf-8") as file:
return json.load(file)
def _sort_builds(builds: List[Dict]) -> List[Dict]:
return sorted(builds, key=lambda build: build.get("number", 0), reverse=True)
def build_history() -> Dict:
"""Return Jenkins build history data."""
history = _load_json("build_history.json")
builds = history.get("builds", [])
return {"builds": _sort_builds(builds)}