mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
filters for SearchTerm
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user