From 4f169970ecb6c077743f70e6d2878f60a4258fb5 Mon Sep 17 00:00:00 2001 From: Egor Date: Sat, 30 Mar 2024 20:49:20 +0300 Subject: [PATCH] :sparkles: sync in storage --- internal/service/syncer/syncer.go | 2 +- internal/storage/storage.go | 23 ----------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/internal/service/syncer/syncer.go b/internal/service/syncer/syncer.go index 9d45b30..d3694cc 100644 --- a/internal/service/syncer/syncer.go +++ b/internal/service/syncer/syncer.go @@ -57,7 +57,7 @@ func (s Syncer) syncServer(server domains.Server) error { currentSyncID := s.repo.GetUserChangeID() - if syncID != currentSyncID { + if syncID == currentSyncID { return nil } diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 98fdf63..0b4bc9a 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -376,29 +376,6 @@ func (s *Storage) GetUserIDByName(username string) (r gost.Result[int]) { return r.Ok(*find) } -func (s *Storage) GetUsersFromSyncID(syncID uint64) (r gost.Result[[]models.User]) { - s.users.RLock() - defer s.users.RUnlock() - - var find []models.User - - s.users.Iter(func(k int, v models.User) (stop bool) { - if v.GetChangeID() < syncID { - find = append(find, v) - } - return false - }) - - return r.Ok(find) -} - -func (s *Storage) GetCurrentSyncID() uint64 { - s.users.RLock() - defer s.users.RUnlock() - - return s.users.changeID -} - func (s *Storage) GetUsersFromChangeID(id uint64) gost.Result[[]models.User] { s.users.RLock() defer s.users.RUnlock()