2019-01-28 12:19:53 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UsersStarProjectsFinder
|
|
|
|
include CustomAttributesFilter
|
|
|
|
|
|
|
|
attr_accessor :params
|
|
|
|
|
2019-02-02 19:53:21 +00:00
|
|
|
def initialize(project, params = {}, current_user: nil)
|
2019-01-28 12:19:53 +00:00
|
|
|
@params = params
|
2019-02-02 19:22:19 +00:00
|
|
|
@project = project
|
|
|
|
@current_user = current_user
|
2019-01-28 12:19:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2019-08-03 10:57:33 +00:00
|
|
|
stars = UsersStarProject.all
|
2019-02-02 19:22:19 +00:00
|
|
|
stars = by_project(stars)
|
2019-01-28 12:19:53 +00:00
|
|
|
stars = by_search(stars)
|
2021-04-19 15:09:08 +00:00
|
|
|
filter_visible_profiles(stars)
|
2019-01-28 12:19:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def by_search(items)
|
2019-01-28 17:51:49 +00:00
|
|
|
params[:search].present? ? items.search(params[:search]) : items
|
2019-01-28 12:19:53 +00:00
|
|
|
end
|
2019-02-02 19:22:19 +00:00
|
|
|
|
|
|
|
def by_project(items)
|
|
|
|
items.by_project(@project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_visible_profiles(items)
|
|
|
|
items.with_visible_profile(@current_user)
|
|
|
|
end
|
2019-01-28 12:19:53 +00:00
|
|
|
end
|