Add build endpoint
This commit is contained in:
22
backend/app/services/builds.py
Normal file
22
backend/app/services/builds.py
Normal 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)}
|
||||
Reference in New Issue
Block a user