Added ApierV1.GetActionPlanIDs and console command to rebuild ActionPlan indexes

This commit is contained in:
Trial97
2019-08-20 13:39:53 +03:00
committed by Dan Christian Bogos
parent f46289828f
commit b7f9c8b7f7
4 changed files with 86 additions and 2 deletions

View File

@@ -1233,3 +1233,21 @@ func (self *ApierV1) ComputeActionPlanIndexes(_ string, reply *string) (err erro
*reply = utils.OK
return nil
}
// GetActionPlanIDs returns list of attributeProfile IDs registered for a tenant
func (apierV1 *ApierV1) GetActionPlanIDs(args utils.TenantArgWithPaginator, attrPrfIDs *[]string) error {
prfx := utils.ACTION_PLAN_PREFIX
keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(utils.ACTION_PLAN_PREFIX)
if err != nil {
return err
}
if len(keys) == 0 {
return utils.ErrNotFound
}
retIDs := make([]string, len(keys))
for i, key := range keys {
retIDs[i] = key[len(prfx):]
}
*attrPrfIDs = args.PaginateStringSlice(retIDs)
return nil
}

View File

@@ -108,7 +108,7 @@ func testVrsDataDB(t *testing.T) {
var result engine.Versions
expectedVrs := engine.Versions{"ActionTriggers": 2,
"Actions": 2, "RQF": 1, "ReverseDestinations": 1, "Attributes": 4, "RatingPlan": 1,
"RatingProfile": 1, "User": 1, "Accounts": 3, "ActionPlans": 2, "Chargers": 1,
"RatingProfile": 1, "User": 1, "Accounts": 3, "ActionPlans": 3, "Chargers": 1,
"Destinations": 1, "SharedGroups": 2, "Stats": 2, "Resource": 1,
"Subscribers": 1, "Suppliers": 1, "Thresholds": 3, "Timing": 1}
if err := vrsRPC.Call("ApierV1.GetDataDBVersions", "", &result); err != nil {
@@ -148,7 +148,7 @@ func testVrsSetDataDBVrs(t *testing.T) {
var result engine.Versions
expectedVrs := engine.Versions{"ActionTriggers": 2,
"Actions": 2, "RQF": 1, "ReverseDestinations": 1, "Attributes": 3, "RatingPlan": 1,
"RatingProfile": 1, "User": 1, "Accounts": 3, "ActionPlans": 2, "Chargers": 1,
"RatingProfile": 1, "User": 1, "Accounts": 3, "ActionPlans": 3, "Chargers": 1,
"Destinations": 1, "SharedGroups": 2, "Stats": 2, "Resource": 1,
"Subscribers": 1, "Suppliers": 1, "Thresholds": 3, "Timing": 1}
if err := vrsRPC.Call("ApierV1.GetDataDBVersions", "", &result); err != nil {

View File

@@ -0,0 +1,65 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdComputeActionPlanIndexes{
name: "actionplan_compute_indexes",
rpcMethod: utils.ApierV1ComputeActionPlanIndexes,
rpcParams: new(EmptyWrapper),
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdComputeActionPlanIndexes struct {
name string
rpcMethod string
rpcParams *EmptyWrapper
*CommandExecuter
}
func (self *CmdComputeActionPlanIndexes) Name() string {
return self.name
}
func (self *CmdComputeActionPlanIndexes) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdComputeActionPlanIndexes) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(EmptyWrapper)
}
return self.rpcParams
}
func (self *CmdComputeActionPlanIndexes) PostprocessRpcParams() error {
return nil
}
func (self *CmdComputeActionPlanIndexes) RpcResult() interface{} {
s := ""
return &s
}

View File

@@ -808,6 +808,7 @@ const (
ApierV1SetDataDBVersions = "ApierV1.SetDataDBVersions"
ApierV1SetStorDBVersions = "ApierV1.SetStorDBVersions"
ApierV1GetAccountActionPlan = "ApierV1.GetAccountActionPlan"
ApierV1ComputeActionPlanIndexes = "ApierV1.ComputeActionPlanIndexes"
)
const (