about summary refs log tree commit diff
path: root/app/models/account.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-15 16:56:29 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-15 16:56:29 +0100
commitfdc17bea58f210f62ac0d9e836b68e84c6dbd15c (patch)
tree491613c94695ba867e81d50124e7e3eb73a0eff5 /app/models/account.rb
parenta91c3ef6cef0fe5a1645c043e7d4a5ef96e82c4f (diff)
Fix rubocop issues, introduce usage of frozen literal to improve performance
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 81b724935..90434f975 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Account < ApplicationRecord
   include Targetable
   include PgSearch
@@ -92,11 +94,11 @@ class Account < ApplicationRecord
   end
 
   def favourited?(status)
-    (status.reblog? ? status.reblog : status).favourites.where(account: self).count > 0
+    (status.reblog? ? status.reblog : status).favourites.where(account: self).count.positive?
   end
 
   def reblogged?(status)
-    (status.reblog? ? status.reblog : status).reblogs.where(account: self).count > 0
+    (status.reblog? ? status.reblog : status).reblogs.where(account: self).count.positive?
   end
 
   def keypair
@@ -115,8 +117,8 @@ class Account < ApplicationRecord
   def avatar_remote_url=(url)
     self.avatar = URI.parse(url) unless self[:avatar_remote_url] == url
     self[:avatar_remote_url] = url
-  rescue OpenURI::HTTPError
-    #
+  rescue OpenURI::HTTPError => e
+    Rails.logger.debug "Error fetching remote avatar: #{e}"
   end
 
   def object_type