From 793d470c0239de0ee08b78e78c1ae9e5b7005570 Mon Sep 17 00:00:00 2001 From: Diogo Biazus Date: Wed, 25 Mar 2015 11:38:57 -0400 Subject: [PATCH] Total contributions and pledged are called more than once in the same request, we don't need to hit the database every time --- app/models/project.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 534f721e09..803872546a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -158,11 +158,11 @@ def expires_at end def pledged - project_total.try(:pledged).to_f + @pledged ||= project_total.try(:pledged).to_f end def total_contributions - project_total.try(:total_contributions).to_i + @total_contributions ||= project_total.try(:total_contributions).to_i end def total_payment_service_fee