Take benchmarks out of real_name, memoize it
This commit is contained in:
parent
cedf4302a7
commit
e8310f2a19
1 changed files with 5 additions and 10 deletions
|
|
@ -68,17 +68,12 @@ class Person
|
||||||
end
|
end
|
||||||
|
|
||||||
def real_name
|
def real_name
|
||||||
result = nil
|
@real_name ||= if profile.first_name.nil? || profile.first_name.empty?
|
||||||
time = Benchmark.realtime do
|
|
||||||
result = if profile.first_name.nil? || profile.first_name.empty?
|
|
||||||
self.diaspora_handle
|
self.diaspora_handle
|
||||||
else
|
else
|
||||||
"#{profile.first_name.to_s} #{profile.last_name.to_s}"
|
"#{profile.first_name.to_s} #{profile.last_name.to_s}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Rails.logger.info "event=real_name ms=#{time}"
|
|
||||||
result
|
|
||||||
end
|
|
||||||
|
|
||||||
def owns?(post)
|
def owns?(post)
|
||||||
self.id == post.person.id
|
self.id == post.person.id
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue