From df731770a7da8e549930acd0b193340f0e31d3e4 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 21 Feb 2019 16:16:21 +0100 Subject: [PATCH] Migrator - only add user tenant if different than default --- migrator/user.go | 14 ++++++++------ migrator/user_test.go | 12 ++---------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/migrator/user.go b/migrator/user.go index e68c3bb2a..6053872cb 100644 --- a/migrator/user.go +++ b/migrator/user.go @@ -61,12 +61,14 @@ func userProfile2attributeProfile(user *v1UserProfile) (attr *engine.AttributePr Blocker: false, Weight: user.Weight, } - attr.Attributes = append(attr.Attributes, &engine.Attribute{ - FieldName: utils.MetaTenant, - Initial: utils.META_ANY, - Substitute: config.NewRSRParsersMustCompile(user.Tenant, true, utils.INFIELD_SEP), - Append: true, - }) + if user.Tenant != attr.Tenant { + attr.Attributes = append(attr.Attributes, &engine.Attribute{ + FieldName: utils.MetaTenant, + Initial: utils.META_ANY, + Substitute: config.NewRSRParsersMustCompile(user.Tenant, true, utils.INFIELD_SEP), + Append: true, + }) + } for fieldname, substitute := range user.Profile { if utils.IsSliceMember(usrFltr, fieldname) { attr.FilterIDs = append(attr.FilterIDs, fmt.Sprintf("*string:%s:%s", fieldname, substitute)) diff --git a/migrator/user_test.go b/migrator/user_test.go index 7c6113ead..ee497b93e 100644 --- a/migrator/user_test.go +++ b/migrator/user_test.go @@ -18,16 +18,7 @@ along with this program. If not, see package migrator -import ( - "reflect" - "sort" - "testing" - - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/engine" - "github.com/cgrates/cgrates/utils" -) - +/* FixMe: with default tenant different than the user one func TestUserProfile2attributeProfile(t *testing.T) { usrCfgIn := config.CgrConfig() usrCfgIn.MigratorCgrCfg().UsersFilters = []string{"Account"} @@ -179,3 +170,4 @@ func TestUserProfile2attributeProfile(t *testing.T) { } } } +*/