filters for SearchTerm

This commit is contained in:
Radu Ioan Fericean
2014-10-03 19:15:21 +03:00
parent e3277373fd
commit 732cd57538
3 changed files with 13 additions and 5 deletions

View File

@@ -226,8 +226,12 @@ type AttrGetAccounts struct {
SearchTerm string
}
func (self *ApierV1) GetAccounts(attr AttrGetAccounts, reply *[]string) error {
accountKeys, err := self.AccountDb.GetKeysForPrefix(engine.ACCOUNT_PREFIX)
func (self *ApierV1) GetAccounts(attrs AttrGetAccounts, reply *[]string) error {
prefix := engine.ACCOUNT_PREFIX
if attrs.SearchTerm != "" {
prefix += "*" + attrs.SearchTerm
}
accountKeys, err := self.AccountDb.GetKeysForPrefix(prefix)
if err != nil {
return err
}

View File

@@ -20,6 +20,7 @@ package v1
import (
"errors"
"strings"
"time"
"github.com/cgrates/cgrates/utils"
@@ -124,6 +125,11 @@ func (self *ApierV1) GetScheduledActions(attrs AttrsGetScheduledActions, reply *
scheduledActions = scheduledActions[min : min+max]
for _, qActions := range scheduledActions {
sas := &ScheduledActions{ActionsId: qActions.ActionsId, ActionPlanId: qActions.Id, ActionPlanUuid: qActions.Uuid}
if paginator.SearchTerm != "" &&
!(strings.Contains(sas.ActionPlanId, paginator.SearchTerm) ||
strings.Contains(sas.ActionsId, paginator.SearchTerm)) {
continue
}
sas.NextRunTime = qActions.GetNextStartTime(time.Now())
if !attrs.TimeStart.IsZero() && sas.NextRunTime.Before(attrs.TimeStart) {
continue // Filter here only requests in the filtered interval

View File

@@ -68,9 +68,7 @@ type Storage interface {
GetKeysForPrefix(string) ([]string, error)
}
/*
Interface for storage providers.
*/
// Interface for storage providers.
type RatingStorage interface {
Storage
CacheRating([]string, []string, []string, []string, []string) error