aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-10-23 17:50:19 +0100
committerLouise Crow <louise.crow@gmail.com>2012-10-23 17:50:19 +0100
commit0e69654a5cd91ac6ef89bb32148d2adb031bd4a2 (patch)
tree95dd30475c7d2f1606512370823ee54e0227509a /app/models/info_request.rb
parentfb2400f6ba050e1bad33a555ffbe7934862e5e33 (diff)
Add an option to calls to calculate_status and display_status to specify that the method can return a value cached on the object by a previous call.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 74a67b9d9..47424e573 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -584,12 +584,11 @@ public
# waiting_classification
# waiting_response_overdue
# waiting_response_very_overdue
- def calculate_status
- if @@custom_states_loaded
- return self.theme_calculate_status
- else
- self.base_calculate_status
+ def calculate_status(cached_value_ok=false)
+ if cached_value_ok && @cached_calculated_status
+ return @cached_calculated_status
end
+ @cached_calculated_status = @@custom_states_loaded ? self.theme_calculate_status : self.base_calculate_status
end
def base_calculate_status
@@ -871,8 +870,8 @@ public
end
end
- def display_status
- InfoRequest.get_status_description(self.calculate_status)
+ def display_status(cached_value_ok=false)
+ InfoRequest.get_status_description(self.calculate_status(cached_value_ok))
end
# Completely delete this request and all objects depending on it