Add UI console and spare forecast naming
This commit is contained in:
@@ -20,6 +20,7 @@ type ticketHandlers struct {
|
||||
|
||||
func RegisterTicketRoutes(mux *http.ServeMux, deps TicketDependencies) {
|
||||
h := ticketHandlers{deps: deps}
|
||||
mux.HandleFunc("/tickets", h.handleTickets)
|
||||
mux.HandleFunc("/connectors/tickets/sync", h.handleTicketSync)
|
||||
}
|
||||
|
||||
@@ -139,6 +140,34 @@ func (h ticketHandlers) handleTicketSync(w http.ResponseWriter, r *http.Request)
|
||||
})
|
||||
}
|
||||
|
||||
func (h ticketHandlers) handleTickets(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
if h.deps.Tickets == nil {
|
||||
writeError(w, http.StatusInternalServerError, "tickets unavailable")
|
||||
return
|
||||
}
|
||||
|
||||
limit := 200
|
||||
if raw := r.URL.Query().Get("limit"); raw != "" {
|
||||
parsed, err := parseIntParam(raw)
|
||||
if err != nil || parsed <= 0 {
|
||||
writeError(w, http.StatusBadRequest, "limit must be a positive integer")
|
||||
return
|
||||
}
|
||||
limit = parsed
|
||||
}
|
||||
|
||||
items, err := h.deps.Tickets.ListAll(r.Context(), limit)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "list tickets failed")
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{"items": items})
|
||||
}
|
||||
|
||||
func parseRFC3339(value *string) (*time.Time, error) {
|
||||
if value == nil || *value == "" {
|
||||
return nil, nil
|
||||
|
||||
Reference in New Issue
Block a user