diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 7096bb8dd..2a79bdb21 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -167,9 +167,7 @@ class StoriesController < ApplicationController redirect_to_changed_username_profile return end - comment_count = params[:view] == "comments" ? 250 : 8 - @comments = @user.comments.where(deleted: false). - order("created_at DESC").includes(:commentable).limit(comment_count) + assign_user_comments @stories = ArticleDecorator.decorate_collection(@user. articles.where(published: true). limited_column_select. @@ -219,7 +217,6 @@ class StoriesController < ApplicationController assign_second_and_third_user not_found if permission_denied? set_surrogate_key_header @article.record_key - @classic_article = Suggester::Articles::Classic.new(@article).get unless user_signed_in? response.headers["Surrogate-Control"] = "max-age=10000, stale-while-revalidate=30, stale-if-error=86400" end @@ -260,6 +257,16 @@ class StoriesController < ApplicationController @user = @article&.user || not_found # The org may have changed back to user and this does not handle that properly end + def assign_user_comments + comment_count = params[:view] == "comments" ? 250 : 8 + @comments = if @user.comments_count > 0 + @user.comments.where(deleted: false). + order("created_at DESC").includes(:commentable).limit(comment_count) + else + [] + end + end + def assign_user_article @user = User.find_by_username(params[:username].downcase) return unless @user diff --git a/app/views/articles/show.html.erb b/app/views/articles/show.html.erb index 58234cbe5..a2eda8df5 100644 --- a/app/views/articles/show.html.erb +++ b/app/views/articles/show.html.erb @@ -207,6 +207,7 @@ <% end %> <% cache("article-bottom-content-#{@article.cached_tag_list_array.sort}", :expires_in => 6.hours) do %> + <% @classic_article = Suggester::Articles::Classic.new(@article).get %> <% if @classic_article %> <%= render "additional_content_boxes/article_box", article: @classic_article, @@ -232,12 +233,6 @@ <% end %> - - -<% if @article.processed_html.include?("interactive-code-wrapper") && @article.user.username == "ben" %> - <%= render 'articles/klipse_script' %> -<% end %> - <% cache("article-show-scripts", expires_in: 6.hours) do %>