mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-21 02:08:40 +02:00
fix merge
Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
parent
010a8bfdc1
commit
664d1388aa
@ -37,6 +37,7 @@ const (
|
|||||||
idQueryCondition = "id = ?"
|
idQueryCondition = "id = ?"
|
||||||
keyQueryCondition = "key = ?"
|
keyQueryCondition = "key = ?"
|
||||||
accountAndIDQueryCondition = "account_id = ? and id = ?"
|
accountAndIDQueryCondition = "account_id = ? and id = ?"
|
||||||
|
accountAndIDsQueryCondition = "account_id = ? AND id IN ?"
|
||||||
accountIDCondition = "account_id = ?"
|
accountIDCondition = "account_id = ?"
|
||||||
peerNotFoundFMT = "peer %s not found"
|
peerNotFoundFMT = "peer %s not found"
|
||||||
)
|
)
|
||||||
@ -1095,10 +1096,11 @@ func (s *SqlStore) GetPeerByID(ctx context.Context, lockStrength LockingStrength
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SqlStore) IncrementNetworkSerial(ctx context.Context, lockStrength LockingStrength, accountId string) error {
|
func (s *SqlStore) IncrementNetworkSerial(ctx context.Context, lockStrength LockingStrength, accountId string) error {
|
||||||
result := s.db.WithContext(ctx).Clauses(clause.Locking{Strength: string(lockStrength)}).
|
result := s.db.Clauses(clause.Locking{Strength: string(lockStrength)}).
|
||||||
Model(&Account{}).Where(idQueryCondition, accountId).Update("network_serial", gorm.Expr("network_serial + 1"))
|
Model(&Account{}).Where(idQueryCondition, accountId).Update("network_serial", gorm.Expr("network_serial + 1"))
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
return status.Errorf(status.Internal, "issue incrementing network serial count: %s", result.Error)
|
log.WithContext(ctx).Errorf("failed to increment network serial count in store: %v", result.Error)
|
||||||
|
return status.Errorf(status.Internal, "failed to increment network serial count in store")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1213,7 +1215,7 @@ func (s *SqlStore) GetGroupByName(ctx context.Context, lockStrength LockingStren
|
|||||||
// GetGroupsByIDs retrieves groups by their IDs and account ID.
|
// GetGroupsByIDs retrieves groups by their IDs and account ID.
|
||||||
func (s *SqlStore) GetGroupsByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, groupIDs []string) (map[string]*nbgroup.Group, error) {
|
func (s *SqlStore) GetGroupsByIDs(ctx context.Context, lockStrength LockingStrength, accountID string, groupIDs []string) (map[string]*nbgroup.Group, error) {
|
||||||
var groups []*nbgroup.Group
|
var groups []*nbgroup.Group
|
||||||
result := s.db.Clauses(clause.Locking{Strength: string(lockStrength)}).Find(&groups, "account_id = ? AND id in ?", accountID, groupIDs)
|
result := s.db.Clauses(clause.Locking{Strength: string(lockStrength)}).Find(&groups, accountAndIDsQueryCondition, accountID, groupIDs)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.WithContext(ctx).Errorf("failed to get groups by ID's from the store: %s", result.Error)
|
log.WithContext(ctx).Errorf("failed to get groups by ID's from the store: %s", result.Error)
|
||||||
return nil, status.Errorf(status.Internal, "failed to get groups by ID's from the store")
|
return nil, status.Errorf(status.Internal, "failed to get groups by ID's from the store")
|
||||||
@ -1256,7 +1258,7 @@ func (s *SqlStore) DeleteGroup(ctx context.Context, lockStrength LockingStrength
|
|||||||
// DeleteGroups deletes groups from the database.
|
// DeleteGroups deletes groups from the database.
|
||||||
func (s *SqlStore) DeleteGroups(ctx context.Context, strength LockingStrength, accountID string, groupIDs []string) error {
|
func (s *SqlStore) DeleteGroups(ctx context.Context, strength LockingStrength, accountID string, groupIDs []string) error {
|
||||||
result := s.db.Clauses(clause.Locking{Strength: string(strength)}).
|
result := s.db.Clauses(clause.Locking{Strength: string(strength)}).
|
||||||
Delete(&nbgroup.Group{}, " account_id = ? AND id IN ?", accountID, groupIDs)
|
Delete(&nbgroup.Group{}, accountAndIDsQueryCondition, accountID, groupIDs)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.WithContext(ctx).Errorf("failed to delete groups from store: %v", result.Error)
|
log.WithContext(ctx).Errorf("failed to delete groups from store: %v", result.Error)
|
||||||
return status.Errorf(status.Internal, "failed to delete groups from store: %v", result.Error)
|
return status.Errorf(status.Internal, "failed to delete groups from store: %v", result.Error)
|
||||||
|
@ -3,7 +3,6 @@ package status
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user