Module: Housekeeping::CombinedScopes::ClassMethods

Defined in:
lib/housekeeping/combined_scopes.rb

Instance Method Summary collapse

Instance Method Details

#recent_from_project_id(project_id) ⇒ Scope

Parameters:

  • project_id (Integer)

Returns:

  • (Scope)


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/housekeeping/combined_scopes.rb', line 24

def recent_from_project_id(project_id)
  t = self.arel_table

  c = t[:project_id].eq(project_id).and(
    t[:created_at].gt(1.weeks.ago).
    or(t[:updated_at].gt(1.weeks.ago)
      )
  )

  where(c.to_sql)
end

#recently_updated(limit) ⇒ Scope

Parameters:

  • limit (Integer)

Returns:

  • (Scope)


38
39
40
# File 'lib/housekeeping/combined_scopes.rb', line 38

def recently_updated(limit)
  self.order(updated_at: :desc).limit(limit)
end

#touched_by(user_id) ⇒ Scope

Parameters:

  • user_id (Integer)

Returns:

  • (Scope)


15
16
17
18
19
20
# File 'lib/housekeeping/combined_scopes.rb', line 15

def touched_by(user_id)
  return self.none if user_id.blank?
  t = self.arel_table
  c = t[:updated_by_id].eq(user_id).or(t[:created_by_id].eq(user_id))
  where(c.to_sql)
end