diff --git a/glance-system/glance-kisfenyo.yaml b/glance-system/glance-kisfenyo.yaml index 77ad8f4..c3fbb90 100644 --- a/glance-system/glance-kisfenyo.yaml +++ b/glance-system/glance-kisfenyo.yaml @@ -630,13 +630,18 @@ data: - type: custom-api title: Meal for the Day cache: 1d - url: ${TANDOOR_URL}/api/recipe/flat/ + + # Use the endpoint that definitely exists in your Tandoor + url: ${TANDOOR_URL}/api/recipe/ headers: Accept: application/json Authorization: Bearer ${TANDOOR_TOKEN} - # We use Prometheus just to get a stable "today" number (Unix time), - # so the 3 picks are deterministic for the day. + # Pass base url into template (NO env() needed) + options: + base_url: ${TANDOOR_URL} + + # Use Prometheus time() to make the pick stable for the day subrequests: epoch: url: ${PROMETHEUS_URL}/api/v1/query @@ -645,71 +650,32 @@ data: template: | - {{ $recipes := .JSON.Array "" }} - {{ $n := len $recipes }} + {{ $base := .Options.String "base_url" }} + {{/* Handle both: array response OR paginated {results:[...]} */}} + {{ $recipes := .JSON.Array "results" }} + {{ if eq (len $recipes) 0 }} + {{ $recipes = .JSON.Array "" }} + {{ end }} + + {{ $n := len $recipes }} {{ if lt $n 1 }}