fix: analytics avg_daily_expense uses selected month/year instead of current
All checks were successful
CI / ci (push) Successful in 13s
All checks were successful
CI / ci (push) Successful in 13s
This commit is contained in:
@@ -253,11 +253,21 @@ func (h *FinanceHandler) Analytics(w http.ResponseWriter, r *http.Request) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
months, _ := strconv.Atoi(r.URL.Query().Get("months"))
|
||||
q := r.URL.Query()
|
||||
months, _ := strconv.Atoi(q.Get("months"))
|
||||
if months <= 0 {
|
||||
months = 6
|
||||
}
|
||||
analytics, err := h.svc.GetAnalytics(userID, months)
|
||||
now := time.Now()
|
||||
month, _ := strconv.Atoi(q.Get("month"))
|
||||
year, _ := strconv.Atoi(q.Get("year"))
|
||||
if month <= 0 {
|
||||
month = int(now.Month())
|
||||
}
|
||||
if year <= 0 {
|
||||
year = now.Year()
|
||||
}
|
||||
analytics, err := h.svc.GetAnalytics(userID, months, month, year)
|
||||
if err != nil {
|
||||
writeError(w, "failed to get analytics", http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user