feat: Implement carrier weight updates, pricing analytics calculations, and tenant rate limiting

- Add updateCarrierWeights implementation with regional and plan-based weight adjustments in carrier_methods.go
- Add calculateRegionalWeightAdjustment helper with usage-based weight scaling and clamping
- Add calculatePlanWeightAdjustment helper with plan usage analysis and adjustment limits
- Add calculateConversionRate helper in pricing_integration.go using discount statistics and active rule ratios
This commit is contained in:
nutcas3
2026-05-02 05:38:06 +03:00
parent 6fc23dff0b
commit 6f8b53f7da
6 changed files with 246 additions and 19 deletions
@@ -5,7 +5,6 @@ import (
"fmt"
"time"
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/id"
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/tenant"
)
@@ -148,14 +147,6 @@ func (s *TenantServiceImpl) GetPerformanceAnalytics(ctx context.Context, tenantI
return analytics, nil
}
func generateUsageID(resourceType, tenantID string) string {
// TODO: Use resourceType and tenantID in ID generation for better traceability
// For now, use generic usage prefix - could be enhanced to include resource type
_ = resourceType // Suppress unused parameter warning until implementation is complete
_ = tenantID // Suppress unused parameter warning until implementation is complete
return id.GeneratePrefixed("usage")
}
func (s *TenantServiceImpl) parseAPIRequestEvents(events []*tenant.TenantEvent) []*tenant.APIRequestEvent {
apiRequests := make([]*tenant.APIRequestEvent, 0)