Module: Housekeeping::CombinedScopes::ClassMethods

Defined in:
lib/housekeeping/combined_scopes.rb

Instance Method Summary (collapse)

Instance Method Details

- (Scope) recent_from_project_id(project_id)

Parameters:

  • project_id (Integer)

Returns:

  • (Scope)


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

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

- (Scope) recently_updated(limit)

Parameters:

  • limit (Integer)

Returns:

  • (Scope)


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

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

- (Scope) touched_by(user_id)

Parameters:

  • user_id (Integer)

Returns:

  • (Scope)


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

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