Class: Gitlab::BackgroundMigration::RecalculateProjectAuthorizationsWithMinMaxUserId

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/background_migration/recalculate_project_authorizations_with_min_max_user_id.rb

Overview

rubocop:disable Style/Documentation

Instance Method Summary collapse

Instance Method Details

#perform(min_user_id, max_user_id) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/background_migration/recalculate_project_authorizations_with_min_max_user_id.rb', line 7

def perform(min_user_id, max_user_id)
  User.where(id: min_user_id..max_user_id).find_each do |user|
    service = Users::RefreshAuthorizedProjectsService.new(
      user,
      incorrect_auth_found_callback:
        ->(project_id, access_level) do
          logger.info(message: 'Removing ProjectAuthorizations',
                      user_id: user.id,
                      project_id: project_id,
                      access_level: access_level)
        end,
      missing_auth_found_callback:
        ->(project_id, access_level) do
          logger.info(message: 'Creating ProjectAuthorizations',
                      user_id: user.id,
                      project_id: project_id,
                      access_level: access_level)
        end
    )

    service.execute
  end
end