feat: Implement revenue analytics calculation, resource performance tracking, and round-robin load balancing

- Add revenue calculation in GetRevenueAnalytics with active subscription base price aggregation
- Add date range filtering for revenue analytics with StartDate and EndDate support
- Add per-plan revenue, subscription count, and average revenue calculations
- Add error handling with partial result fallback for revenue queries
- Replace mock resource performance with event-based performance
This commit is contained in:
nutcas3
2026-05-02 17:56:34 +03:00
parent 4241c38389
commit 5fddd48994
5 changed files with 111 additions and 26 deletions
@@ -8,8 +8,9 @@ import (
// LoadBalancer implements different load balancing strategies for carrier selection
type LoadBalancer struct {
strategy LoadBalancingStrategy
rand *rand.Rand
strategy LoadBalancingStrategy
rand *rand.Rand
rrCounter uint64 // round-robin request counter
}
// LoadBalancingStrategy defines the load balancing algorithm
@@ -55,9 +56,9 @@ func (lb *LoadBalancer) SelectCarrier(carriers []*Carrier, req *ProfileRequest)
// roundRobinSelect implements round-robin carrier selection
func (lb *LoadBalancer) roundRobinSelect(carriers []*Carrier) *Carrier {
// Simple round-robin based on request count
// In a real implementation, you'd maintain state across requests
return carriers[0] // Simplified for demo
idx := lb.rrCounter % uint64(len(carriers))
lb.rrCounter++
return carriers[idx]
}
// weightedRoundRobinSelect selects carrier based on priority and health