From 1edb5919fa1b565ae185b8ddd4ec2987fe801841 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 25 Jun 2015 17:19:32 +1000 Subject: [PATCH] PERF: don't count all likes twice on like --- app/models/post_action.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/post_action.rb b/app/models/post_action.rb index f1746196a99..20c0d62007c 100644 --- a/app/models/post_action.rb +++ b/app/models/post_action.rb @@ -280,9 +280,12 @@ SQL end # agree with other flags - PostAction.agree_flags!(post, user) if staff_took_action - # update counters - post_action.try(:update_counters) + if staff_took_action + PostAction.agree_flags!(post, user) + + # update counters + post_action.try(:update_counters) + end post_action rescue ActiveRecord::RecordNotUnique