debian-mirror-gitlab/app/finders/users_star_projects_finder.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
675 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
class UsersStarProjectsFinder
include CustomAttributesFilter
attr_accessor :params
def initialize(project, params = {}, current_user: nil)
@params = params
@project = project
@current_user = current_user
end
def execute
stars = UsersStarProject.all
stars = by_project(stars)
stars = by_search(stars)
2021-04-29 21:17:54 +05:30
filter_visible_profiles(stars)
2019-10-12 21:52:04 +05:30
end
private
def by_search(items)
params[:search].present? ? items.search(params[:search]) : items
end
def by_project(items)
items.by_project(@project)
end
def filter_visible_profiles(items)
items.with_visible_profile(@current_user)
end
end