Refactor code to use 'any' type and improve context handling
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-18 16:16:27 +11:00
parent 6517a30fa2
commit f2d6b3158b
36 changed files with 197 additions and 175 deletions

View File

@@ -1,7 +1,6 @@
package handler
import (
"context"
"fmt"
"net/http"
"net/url"
@@ -58,7 +57,8 @@ func (h *Handler) SnapshotMonthlyList(w http.ResponseWriter, r *http.Request) {
// @Failure 500 {object} models.ErrorResponse "Server error"
// @Router /api/report/snapshot [get]
func (h *Handler) SnapshotReportDownload(w http.ResponseWriter, r *http.Request) {
ctx := context.Background()
ctx, cancel := withRequestTimeout(r, reportRequestTimeout)
defer cancel()
tableName := r.URL.Query().Get("table")
if tableName == "" {
writeJSONError(w, http.StatusBadRequest, "Missing table parameter")
@@ -80,7 +80,8 @@ func (h *Handler) SnapshotReportDownload(w http.ResponseWriter, r *http.Request)
}
func (h *Handler) renderSnapshotList(w http.ResponseWriter, r *http.Request, snapshotType string, title string, renderer func([]views.SnapshotEntry) templ.Component) {
ctx := context.Background()
ctx, cancel := withRequestTimeout(r, defaultRequestTimeout)
defer cancel()
if err := report.EnsureSnapshotRegistry(ctx, h.Database); err != nil {
h.Logger.Error("Failed to ensure snapshot registry", "error", err)
w.WriteHeader(http.StatusInternalServerError)
@@ -107,10 +108,7 @@ func (h *Handler) renderSnapshotList(w http.ResponseWriter, r *http.Request, sna
case "monthly":
group = record.SnapshotTime.Format("2006")
}
count := record.SnapshotCount
if count < 0 {
count = 0
}
count := max(record.SnapshotCount, 0)
entries = append(entries, views.SnapshotEntry{
Label: label,
Link: "/reports/" + url.PathEscape(record.TableName) + ".xlsx",