Remove Account.Rules from Store engines (#1528)

This commit is contained in:
Yury Gargay
2024-02-19 17:17:36 +01:00
committed by GitHub
parent cb3408a10b
commit db3cba5e0f
6 changed files with 106 additions and 156 deletions

View File

@@ -156,11 +156,6 @@ func (s *SqliteStore) SaveAccount(account *Account) error {
account.GroupsG = append(account.GroupsG, *group)
}
for id, rule := range account.Rules {
rule.ID = id
account.RulesG = append(account.RulesG, *rule)
}
for id, route := range account.Routes {
route.ID = id
account.RoutesG = append(account.RoutesG, *route)
@@ -356,7 +351,6 @@ func (s *SqliteStore) GetAllAccounts() (all []*Account) {
func (s *SqliteStore) GetAccount(accountID string) (*Account, error) {
var account Account
result := s.db.Model(&account).
Preload("UsersG.PATsG"). // have to be specifies as this is nester reference
Preload(clause.Associations).
@@ -403,12 +397,6 @@ func (s *SqliteStore) GetAccount(accountID string) (*Account, error) {
}
account.GroupsG = nil
account.Rules = make(map[string]*Rule, len(account.RulesG))
for _, rule := range account.RulesG {
account.Rules[rule.ID] = rule.Copy()
}
account.RulesG = nil
account.Routes = make(map[string]*route.Route, len(account.RoutesG))
for _, route := range account.RoutesG {
account.Routes[route.ID] = route.Copy()