package handlers

import (
	"net/http"
	"time"
)

func (h *Handler) Health(writer http.ResponseWriter, request *http.Request) {
	rows, lastReset, nextReset := h.store.Snapshot()
	WriteJSON(writer, http.StatusOK, map[string]any{
		"status":         "ok",
		"service":        h.appName,
		"version":        h.version,
		"dataset_count":  len(rows),
		"reset_interval": h.store.ResetInterval().String(),
		"last_reset":     lastReset.Format(time.RFC3339),
		"next_reset":     nextReset.Format(time.RFC3339),
	})
}
