mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-30 00:22:15 +00:00
refactor: Replace interface{} with any and optimize slice operations
- Replace map[string]interface{} with map[string]any in UpdateCarrierMetrics
- Replace interface{} with any for GeneratedAt field in PricingEffectiveness struct
- Replace loop-based empty string checks with slices.Contains in ValidateConditions
- Replace range loop index initialization with range-only syntax in calculateAPIPerformance
- Add slices import for standard library slice utilities
This commit is contained in:
@@ -109,7 +109,7 @@ func (r *GormCarrierRepository) SaveCarrier(ctx context.Context, carrier *smdp.C
|
|||||||
// UpdateCarrierMetrics updates carrier metrics
|
// UpdateCarrierMetrics updates carrier metrics
|
||||||
func (r *GormCarrierRepository) UpdateCarrierMetrics(ctx context.Context, id string, metrics *smdp.CarrierMetrics) error {
|
func (r *GormCarrierRepository) UpdateCarrierMetrics(ctx context.Context, id string, metrics *smdp.CarrierMetrics) error {
|
||||||
// Persist metrics alongside the carrier record
|
// Persist metrics alongside the carrier record
|
||||||
updates := map[string]interface{}{
|
updates := map[string]any{
|
||||||
"updated_at": time.Now(),
|
"updated_at": time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ type PricingEffectiveness struct {
|
|||||||
TotalSavings float64 `json:"total_savings"`
|
TotalSavings float64 `json:"total_savings"`
|
||||||
RulesByType map[string]int `json:"rules_by_type"`
|
RulesByType map[string]int `json:"rules_by_type"`
|
||||||
ConversionImprovement float64 `json:"conversion_improvement"`
|
ConversionImprovement float64 `json:"conversion_improvement"`
|
||||||
GeneratedAt interface{} `json:"generated_at"`
|
GeneratedAt any `json:"generated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RatePlanPricingAnalytics struct {
|
type RatePlanPricingAnalytics struct {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/pricing"
|
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/pricing"
|
||||||
)
|
)
|
||||||
@@ -121,17 +122,13 @@ func (v *PricingValidator) ValidateConditions(ctx context.Context, conditions pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate geography
|
// Validate geography
|
||||||
for _, geo := range conditions.Geography {
|
if slices.Contains(conditions.Geography, "") {
|
||||||
if geo == "" {
|
return errors.New("geography cannot be empty")
|
||||||
return errors.New("geography cannot be empty")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate customer type
|
// Validate customer type
|
||||||
for _, ct := range conditions.CustomerType {
|
if slices.Contains(conditions.CustomerType, "") {
|
||||||
if ct == "" {
|
return errors.New("customer type cannot be empty")
|
||||||
return errors.New("customer type cannot be empty")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate volume range
|
// Validate volume range
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ func (s *TenantServiceImpl) calculateAPIPerformance(requests []*tenant.APIReques
|
|||||||
copy(sortedResponseTimes, responseTimes)
|
copy(sortedResponseTimes, responseTimes)
|
||||||
|
|
||||||
// Sort response times
|
// Sort response times
|
||||||
for i := 0; i < len(sortedResponseTimes); i++ {
|
for i := range sortedResponseTimes {
|
||||||
for j := 0; j < len(sortedResponseTimes)-1-i; j++ {
|
for j := 0; j < len(sortedResponseTimes)-1-i; j++ {
|
||||||
if sortedResponseTimes[j] > sortedResponseTimes[j+1] {
|
if sortedResponseTimes[j] > sortedResponseTimes[j+1] {
|
||||||
sortedResponseTimes[j], sortedResponseTimes[j+1] = sortedResponseTimes[j+1], sortedResponseTimes[j]
|
sortedResponseTimes[j], sortedResponseTimes[j+1] = sortedResponseTimes[j+1], sortedResponseTimes[j]
|
||||||
|
|||||||
Reference in New Issue
Block a user