diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb index 199a0fb9c4a..d615fc54229 100644 --- a/app/controllers/embed_controller.rb +++ b/app/controllers/embed_controller.rb @@ -28,11 +28,14 @@ class EmbedController < ApplicationController def count - topic_embeds = TopicEmbed.where(embed_url: params[:embed_url]).includes(:topic).all + urls = params[:embed_url].map {|u| u.sub(/#discourse-comments$/, '') } + topic_embeds = TopicEmbed.where(embed_url: urls).includes(:topic).references(:topic) by_url = {} topic_embeds.each do |te| - by_url["#{te.embed_url}#discourse-comments"] = I18n.t('embed.replies', count: te.topic.posts_count - 1) + url = te.embed_url + url = "#{url}#discourse-comments" unless params[:embed_url].include?(url) + by_url[url] = I18n.t('embed.replies', count: te.topic.posts_count - 1) end respond_to do |format| diff --git a/public/javascripts/count.js b/public/javascripts/count.js index 6fc942a1098..97d891215e6 100644 --- a/public/javascripts/count.js +++ b/public/javascripts/count.js @@ -8,13 +8,20 @@ countFor = []; for(var i=0; i