diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 4828e1827..b336a924a 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -13,7 +13,6 @@ class DebatesController < ApplicationController @debates = @debates.page(params[:page]).for_render.send("sort_by_#{@order}") @tag_cloud = Debate.tag_counts.order(taggings_count: :desc, name: :asc).limit(20) set_debate_votes(@debates) - ahoy.track_visit end def show @@ -24,7 +23,6 @@ class DebatesController < ApplicationController @all_visible_comments = @root_comments + @comments set_comment_flags(@all_visible_comments) - ahoy.track_visit end def new diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 595de397f..fe224eb8d 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -4,7 +4,6 @@ class StatsController < ApplicationController def show @event_types = Ahoy::Event.select(:name).uniq.pluck(:name) - @debates_created_count = Ahoy::Event.where(name: 'debate_created').count end private diff --git a/app/helpers/cache_keys_helper.rb b/app/helpers/cache_keys_helper.rb index 6bcd8ca91..be23439dd 100644 --- a/app/helpers/cache_keys_helper.rb +++ b/app/helpers/cache_keys_helper.rb @@ -22,4 +22,9 @@ module CacheKeysHelper user_status end + # when commentable id and type are used but no need to update cache on updated_at changes + def commentable_cache_key(commentable) + "#{commentable.class.name}-#{commentable.id}" + end + end \ No newline at end of file diff --git a/app/jobs/stats_job.rb b/app/jobs/stats_job.rb deleted file mode 100644 index 14e530bc5..000000000 --- a/app/jobs/stats_job.rb +++ /dev/null @@ -1,6 +0,0 @@ -class StatsJob < ActiveJob::Base - queue_as :default - - def perform(*args) - end -end diff --git a/app/models/comment.rb b/app/models/comment.rb index 657994d8e..5997276d0 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -4,7 +4,7 @@ class Comment < ActiveRecord::Base acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases acts_as_votable - has_ancestry + has_ancestry touch: true attr_accessor :as_moderator, :as_administrator diff --git a/app/models/debate.rb b/app/models/debate.rb index e976bcef9..645d6146b 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -39,6 +39,9 @@ class Debate < ActiveRecord::Base scope :sort_by_most_commented, -> { order(comments_count: :desc) } scope :sort_by_random, -> { order("RANDOM()") } + # Ahoy setup + visitable # Ahoy will automatically assign visit_id on create + def likes cached_votes_up end diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index d29c19ebe..0ac6b9be1 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,102 +1,104 @@ -
<%= t("debates.comment.deleted") %>
-<%= t("debates.comment.deleted") %>
+
<%= comment.body %>
+ <% elsif comment.as_moderator? %> +<%= comment.body %>
+ <% elsif comment.user.official? && comment.user_id == @commentable.author_id %> +<%= comment.body %>
+ <% elsif comment.user.official? %> +<%= comment.body %>
+ <% elsif comment.user_id == @commentable.author_id %> +<%= comment.body %>
+ <% else %> +<%= comment.body %>
<% end %> + + <%= render 'comments/votes', comment: comment %> + - • <%= time_ago_in_words(comment.created_at) %> +<%= comment.body %>
- <% elsif comment.as_moderator? %> -<%= comment.body %>
- <% elsif comment.user.official? && comment.user_id == @commentable.author_id %> -<%= comment.body %>
- <% elsif comment.user.official? %> -<%= comment.body %>
- <% elsif comment.user_id == @commentable.author_id %> -<%= comment.body %>
- <% else %> -<%= comment.body %>
+ <% end %> +