Class: UserRecentEventsFinder

Inherits:
Object
  • Object
show all
Includes:
FinderMethods, FinderWithCrossProjectAccess, Gitlab::Allowable
Defined in:
app/finders/user_recent_events_finder.rb

Overview

Get user activity feed for projects common for a user and a logged in user

  • current_user: The user viewing the events

    WARNING: does not consider project feature visibility!
    
  • user: The user for which to load the events

  • params:

    • limit: Number of items that to be returned. Defaults to 20 and limited to 100.

    • offset: The page of events to return

Constant Summary collapse

DEFAULT_LIMIT =
20
MAX_LIMIT =
100

Instance Attribute Summary collapse

Attributes included from FinderWithCrossProjectAccess

#should_skip_cross_project_check

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?

Methods included from FinderMethods

#find, #find_by, #find_by!

Methods included from FinderWithCrossProjectAccess

#can_read_cross_project?, #can_read_project?, #find, #find_by, #find_by!, #skip_cross_project_check

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Constructor Details

#initialize(current_user, target_user, event_filter, params = {}) ⇒ UserRecentEventsFinder

Returns a new instance of UserRecentEventsFinder.


23
24
25
26
27
28
# File 'app/finders/user_recent_events_finder.rb', line 23

def initialize(current_user, target_user, event_filter, params = {})
  @current_user = current_user
  @target_user = target_user
  @params = params
  @event_filter = event_filter || EventFilter.new(EventFilter::ALL)
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.


18
19
20
# File 'app/finders/user_recent_events_finder.rb', line 18

def current_user
  @current_user
end

#event_filterObject (readonly)

Returns the value of attribute event_filter.


18
19
20
# File 'app/finders/user_recent_events_finder.rb', line 18

def event_filter
  @event_filter
end

#paramsObject (readonly)

Returns the value of attribute params.


18
19
20
# File 'app/finders/user_recent_events_finder.rb', line 18

def params
  @params
end

#target_userObject (readonly)

Returns the value of attribute target_user.


18
19
20
# File 'app/finders/user_recent_events_finder.rb', line 18

def target_user
  @target_user
end

Instance Method Details

#executeObject


30
31
32
33
34
35
36
# File 'app/finders/user_recent_events_finder.rb', line 30

def execute
  if target_user.is_a? User
    execute_single
  else
    execute_multi
  end
end