Welcome to mirror list, hosted at ThFree Co, Russian Federation.

move_users_star_projects_service.rb « projects « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 20121d429e2f5711e9bdcf62d7cc97ea9f248ace (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module Projects
  class MoveUsersStarProjectsService < BaseMoveRelationsService
    def execute(source_project, remove_remaining_elements: true)
      return unless super

      user_stars = source_project.users_star_projects

      return unless user_stars.any?

      Project.transaction(requires_new: true) do
        user_stars.update_all(project_id: @project.id)

        Project.reset_counters @project.id, :users_star_projects
        Project.reset_counters source_project.id, :users_star_projects

        success
      end
    end
  end
end