2019-01-28 07:19:53 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UsersStarProjectsFinder
|
|
|
|
include CustomAttributesFilter
|
|
|
|
|
|
|
|
attr_accessor :params
|
|
|
|
|
2019-02-02 14:53:21 -05:00
|
|
|
def initialize(project, params = {}, current_user: nil)
|
2019-01-28 07:19:53 -05:00
|
|
|
@params = params
|
2019-02-02 14:22:19 -05:00
|
|
|
@project = project
|
|
|
|
@current_user = current_user
|
2019-01-28 07:19:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2022-10-21 05:10:32 -04:00
|
|
|
stars = UsersStarProject.with_active_user
|
2019-02-02 14:22:19 -05:00
|
|
|
stars = by_project(stars)
|
2019-01-28 07:19:53 -05:00
|
|
|
stars = by_search(stars)
|
2021-04-19 11:09:08 -04:00
|
|
|
filter_visible_profiles(stars)
|
2019-01-28 07:19:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def by_search(items)
|
2019-01-28 12:51:49 -05:00
|
|
|
params[:search].present? ? items.search(params[:search]) : items
|
2019-01-28 07:19:53 -05:00
|
|
|
end
|
2019-02-02 14:22:19 -05: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 07:19:53 -05:00
|
|
|
end
|