Class: ActivityFeed
- Inherits:
-
Object
- Object
- ActivityFeed
- Defined in:
- app/models/activity_feed.rb
Defined Under Namespace
Classes: Event, ReleaseEvent, TicketClosedEvent, TicketCreatedEvent, TicketEvent
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #events ⇒ Object
-
#initialize(projects, time, options = {}) ⇒ ActivityFeed
constructor
A new instance of ActivityFeed.
- #releases ⇒ Object
- #ticket_closures ⇒ Object
- #ticket_creations ⇒ Object
Constructor Details
#initialize(projects, time, options = {}) ⇒ ActivityFeed
Returns a new instance of ActivityFeed.
3 4 5 6 7 |
# File 'app/models/activity_feed.rb', line 3 def initialize(projects, time, ={}) @projects = projects @time = time @count = .fetch(:count, 25) end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
9 10 11 |
# File 'app/models/activity_feed.rb', line 9 def count @count end |
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
9 10 11 |
# File 'app/models/activity_feed.rb', line 9 def projects @projects end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
9 10 11 |
# File 'app/models/activity_feed.rb', line 9 def time @time end |
Instance Method Details
#events ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/models/activity_feed.rb', line 11 def events @events ||= ( ticket_creations + ticket_closures + releases) .sort_by(&:time) .reverse .take(count) end |
#releases ⇒ Object
31 32 33 34 |
# File 'app/models/activity_feed.rb', line 31 def releases Release.for_projects(projects).includes(:project, :user).before(time).limit(count) .map { |release| ReleaseEvent.new(release) } end |
#ticket_closures ⇒ Object
26 27 28 29 |
# File 'app/models/activity_feed.rb', line 26 def ticket_closures Ticket.for_projects(projects).includes(:project, :reporter).closed_before(time).limit(count) .map { |ticket| TicketClosedEvent.new(ticket) } end |
#ticket_creations ⇒ Object
21 22 23 24 |
# File 'app/models/activity_feed.rb', line 21 def ticket_creations Ticket.for_projects(projects).includes(:project, :reporter).created_before(time).limit(count) .map { |ticket| TicketCreatedEvent.new(ticket) } end |