Class: Gitlab::BackgroundMigration::RecalculateProjectAuthorizations

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

Overview

rubocop:disable Style/Documentation

Instance Method Summary collapse

Instance Method Details

#perform(user_ids) ⇒ Object


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

def perform(user_ids)
  user_ids.each do |user_id|
    user = User.find_by(id: user_id)

    next unless 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