about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-08 20:36:01 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-08 20:36:01 +0200
commit85d89b472dff2c3d06801dbd42f91c325d21a434 (patch)
treeb348297bf48c63f906cdcdbc1ff573203afb560a /app/helpers
parenta4cc966476852542f445793b60c67ad3682976e5 (diff)
Optimized n+1 queries in accounts Atom and HTML views
Added stack trace for SQL queries in development
Removed badly thought out accounts/lookup API
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/api/accounts/lookup_helper.rb2
-rw-r--r--app/helpers/application_helper.rb19
-rw-r--r--app/helpers/stream_entries_helper.rb4
3 files changed, 13 insertions, 12 deletions
diff --git a/app/helpers/api/accounts/lookup_helper.rb b/app/helpers/api/accounts/lookup_helper.rb
deleted file mode 100644
index 5caf0e28c..000000000
--- a/app/helpers/api/accounts/lookup_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module Api::Accounts::LookupHelper
-end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e0105ee54..e43875544 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -22,23 +22,26 @@ module ApplicationHelper
 
   def account_from_mentions(search_string, mentions)
     mentions.each { |x| return x.account if x.account.acct.eql?(search_string) }
+    nil
 
     # If that was unsuccessful, try fetching user from db separately
     # But this shouldn't ever happen if the mentions were created correctly!
-    username, domain = search_string.split('@')
+    # username, domain = search_string.split('@')
 
-    if domain == Rails.configuration.x.local_domain
-      account = Account.find_local(username)
-    else
-      account = Account.find_remote(username, domain)
-    end
+    # if domain == Rails.configuration.x.local_domain
+    #   account = Account.find_local(username)
+    # else
+    #   account = Account.find_remote(username, domain)
+    # end
 
-    account
+    # account
   end
 
   def linkify(status)
     auto_link(HTMLEntities.new.encode(status.text), link: :urls, html: { rel: 'nofollow noopener' }).gsub(Account::MENTION_RE) do |m|
-      if account = account_from_mentions(Account::MENTION_RE.match(m)[1], status.mentions)
+      account = account_from_mentions(Account::MENTION_RE.match(m)[1], status.mentions)
+
+      unless account.nil?
         "#{m.split('@').first}<a href=\"#{url_for_target(account)}\" class=\"mention\">@<span>#{account.acct}</span></a>"
       else
         m
diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb
index a29014d1b..ce77206ea 100644
--- a/app/helpers/stream_entries_helper.rb
+++ b/app/helpers/stream_entries_helper.rb
@@ -21,11 +21,11 @@ module StreamEntriesHelper
   end
 
   def reblogged_by_me_class(status)
-    user_signed_in? && current_user.account.reblogged?(status) ? 'reblogged' : ''
+    user_signed_in? && @reblogged.has_key?(status.id) ? 'reblogged' : ''
   end
 
   def favourited_by_me_class(status)
-    user_signed_in? && current_user.account.favourited?(status) ? 'favourited' : ''
+    user_signed_in? && @favourited.has_key?(status.id) ? 'favourited' : ''
   end
 
   def proper_status(status)