Skip to content

Commit

Permalink
Preload acknowledge and reciprocate messages per activity
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanPorta committed Nov 9, 2014
1 parent 7bb92f7 commit 4063b09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/decorators/activity_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ def activity_message
end
end

def reciprocate_message
unacknowledged_message_for_sender
end

def acknowledge_message
acknowledged_message_for_recipient
end

private

def acknowledged_message_for_sender
Expand Down
2 changes: 1 addition & 1 deletion app/views/activities/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
json.array!(@activities) do |activity|
activity = activity.decorate
json.extract! activity, :id, :type, :activity_message
json.extract! activity, :id, :type, :activity_message, :reciprocate_message, :acknowledge_message
json.message do
# Sadly, this step is needed because extract doesn't find the at_in_words methods from the decorator.
json.extract! activity.message, :id, :verb, :sender, :recipient, :acknowledged_at, :acknowledged_at_in_words, :created_at, :created_at_in_words
Expand Down

0 comments on commit 4063b09

Please sign in to comment.