Add build endpoint

This commit is contained in:
jose-rZM
2025-12-15 12:52:10 +01:00
parent 80b9f4cb9f
commit 16ff8b1380
2 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
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)}