mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
added trend dynamicDP in filters and GetTrendSummary API
This commit is contained in:
committed by
Dan Christian Bogos
parent
dd59fcb553
commit
2e192dde78
@@ -29,12 +29,13 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func newDynamicDP(resConns, stsConns, apiConns []string,
|
||||
func newDynamicDP(resConns, stsConns, apiConns, trdConns []string,
|
||||
tenant string, initialDP utils.DataProvider) *dynamicDP {
|
||||
return &dynamicDP{
|
||||
resConns: resConns,
|
||||
stsConns: stsConns,
|
||||
apiConns: apiConns,
|
||||
trdConns: trdConns,
|
||||
tenant: tenant,
|
||||
initialDP: initialDP,
|
||||
cache: utils.MapStorage{},
|
||||
@@ -45,6 +46,7 @@ type dynamicDP struct {
|
||||
resConns []string
|
||||
stsConns []string
|
||||
apiConns []string
|
||||
trdConns []string
|
||||
tenant string
|
||||
initialDP utils.DataProvider
|
||||
|
||||
@@ -142,6 +144,15 @@ func (dDP *dynamicDP) fieldAsInterface(fldPath []string) (val any, err error) {
|
||||
dDP.cache.Set([]string{utils.MetaStats, fldPath[1], k}, v)
|
||||
}
|
||||
return dDP.cache.FieldAsInterface(fldPath)
|
||||
case utils.MetaTrends:
|
||||
//sample of fieldName : ~*trends.TrendID.*acd.Value
|
||||
var trendSum TrendSummary
|
||||
if err := connMgr.Call(context.TODO(), dDP.trdConns, utils.TrendSv1GetTrendSummary, &utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: dDP.tenant, ID: fldPath[1]}}, &trendSum); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := config.NewObjectDP(trendSum)
|
||||
dDP.cache.Set(fldPath[:2], dp)
|
||||
return dp.FieldAsInterface(fldPath[2:])
|
||||
case utils.MetaLibPhoneNumber:
|
||||
// sample of fieldName ~*libphonenumber.<~*req.Destination>
|
||||
// or ~*libphonenumber.<~*req.Destination>.Carrier
|
||||
|
||||
Reference in New Issue
Block a user