refactor: Extract helper methods, fix formatting, and add TODO comments for pending implementations

- Extract generateHistoryAnalytics helper in selection_handler_methods.go
- Extract generateRecommendations helper in selection_handler_selection.go
- Extract parsePositiveInt helper in rateplan_handlers_analytics.go
- Replace hardcoded URL path with action parameter in ES2Service.sendActivationRequest
- Add TODO comments for wrapCurrencyService and updateCarrierWeights pending implementations
- Fix struct field alignment and formatting in carrier_methods.go
This commit is contained in:
nutcas3
2026-05-02 05:08:43 +03:00
parent d2bd13eff6
commit ec812835c8
6 changed files with 40 additions and 46 deletions
@@ -2,7 +2,6 @@ package handlers
import (
"net/http"
"strconv"
"time"
"github.com/gin-gonic/gin"
@@ -111,12 +110,7 @@ func (h *RatePlanHandler) GetRevenueAnalytics(c *gin.Context) {
// GetPopularPlans handles retrieving the most popular rate plans
func (h *RatePlanHandler) GetPopularPlans(c *gin.Context) {
limit := 10 // default limit
if limitStr := c.Query("limit"); limitStr != "" {
if parsedLimit, err := strconv.Atoi(limitStr); err == nil && parsedLimit > 0 {
limit = parsedLimit
}
}
limit := parsePositiveInt(c.Query("limit"), 10)
plans, err := h.service.GetPopularPlans(c.Request.Context(), limit)
if err != nil {
@@ -3,7 +3,6 @@ package handlers
import (
"encoding/json"
"net/http"
"time"
)
// GetSelectionHistory handles the selection history endpoint
@@ -24,10 +23,7 @@ func (h *SelectionHandler) GetSelectionHistory(w http.ResponseWriter, r *http.Re
history := h.manager.GetSelectionHistory(carrierID)
// Generate analytics
analytics := map[string]any{
"total_selections": len(history),
"generated_at": time.Now().Format(time.RFC3339),
}
analytics := h.generateHistoryAnalytics(history)
response := SelectionHistoryResponse{
Success: true,
@@ -55,7 +55,7 @@ func (h *SelectionHandler) SelectOptimalCarrier(w http.ResponseWriter, r *http.R
}
// Generate recommendations
recommendations := []string{"Carrier selected successfully"}
recommendations := h.generateRecommendations(score, criteria)
response := SelectOptimalCarrierResponse{
Success: true,
@@ -69,7 +69,7 @@ func (h *SelectionHandler) SelectOptimalCarrier(w http.ResponseWriter, r *http.R
CapabilityScore: score.CapabilityScore,
SelectedAt: score.SelectedAt.Format(time.RFC3339),
Reason: score.Reason,
Recommendations: recommendations,
Recommendations: recommendations,
}
h.writeJSONResponse(w, http.StatusOK, response)