Class: ContributedProjectsFinder
- Inherits:
-
Object
- Object
- ContributedProjectsFinder
- Includes:
- Projects::SearchFilter
- Defined in:
- app/finders/contributed_projects_finder.rb
Overview
Finds the projects “@user” contributed to, limited to either public projects or projects visible to the given user.
Arguments:
user: User to find contributed projects for
current_user: The current user
params:
search: Return only projects that match search filter
ignore_visibility: When true the list of projects will include all contributed
projects, regardless of their visibility to the current_user.
min_access_level: Return only projects where user has at least the access level.
programming_language_name: Return only projects that use the provided programming language.
sort: Order projects
Returns an ActiveRecord::Relation.
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(user:, current_user: nil, params: {}) ⇒ ContributedProjectsFinder
constructor
A new instance of ContributedProjectsFinder.
Constructor Details
#initialize(user:, current_user: nil, params: {}) ⇒ ContributedProjectsFinder
Returns a new instance of ContributedProjectsFinder.
23 24 25 26 27 |
# File 'app/finders/contributed_projects_finder.rb', line 23 def initialize(user:, current_user: nil, params: {}) @user = user @current_user = current_user @params = params end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
21 22 23 |
# File 'app/finders/contributed_projects_finder.rb', line 21 def current_user @current_user end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
21 22 23 |
# File 'app/finders/contributed_projects_finder.rb', line 21 def params @params end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
21 22 23 |
# File 'app/finders/contributed_projects_finder.rb', line 21 def user @user end |
Instance Method Details
#execute ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/finders/contributed_projects_finder.rb', line 29 def execute # Do not show contributed projects if the user profile is private. return Project.none unless can_read_profile?(current_user) collection = init_collection collection = filter_projects(collection) collection.with_namespace.sort_by_attribute(params[:sort] || 'id_desc') end |