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

users_star_projects_finder.rb « finders « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 66b83fa8f8efbf689e2217390b59bcb01072596e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

class UsersStarProjectsFinder
  include CustomAttributesFilter

  attr_accessor :params

  def initialize(params = {})
    @params = params
  end

  def execute
    stars = UsersStarProject.all.order_id_desc
    stars = by_search(stars)
    stars = by_project(stars)

    stars
  end

  private

  def by_search(items)
    return items unless params[:search].present?

    items.search(params[:search])
  end

  def by_project(items)
    params[:project].present? ? items.by_project(params[:project]) : items
  end
end