2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
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?
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
Project.transaction do
|
2018-05-09 12:01:36 +05:30
|
|
|
user_stars.update_all(project_id: @project.id)
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
@project.update(star_count: @project.starrers.with_state(:active).size)
|
|
|
|
source_project.update(star_count: source_project.starrers.with_state(:active).size)
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
success
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|