Topic: another performance question
i am having another performance issuse.
i have a function in a model that looks like this
wet_time = 0
self.status_changes.each do |change|
next_change = get_next_change(change.date_time)
if ! next_change.nil?
diff = next_change.date_time.to_i - change.date_time.to_i
wet_time += diff
now to get total_wet_time, the whole list is pulled for the self.status_changes ( usually about 300 records each.
now in the same page, i use this value to compute a few different values that will also be displayed. And each time it has to go through this whole process again. This makes a huge drag on the page loading.
so, i was wondering, is there something i can put in here that if this value has already been computed, it will return that value instead of going through all this over and over again ?