diff --git a/app/assets/javascripts/discourse/controllers/group.js.es6 b/app/assets/javascripts/discourse/controllers/group.js.es6 index 2c72b5475a6..b7382ed98c4 100644 --- a/app/assets/javascripts/discourse/controllers/group.js.es6 +++ b/app/assets/javascripts/discourse/controllers/group.js.es6 @@ -38,12 +38,9 @@ export default Ember.Controller.extend({ }; }, - @observes('counts') - countsChanged() { - const counts = this.get('counts'); - this.get('tabs').forEach(tab => { - tab.set('count', counts.get(tab.get('name'))); - }); + @observes('model.user_count') + _setMembersTabCount() { + this.get('tabs')[0].set('count', this.get('model.user_count')); }, @observes('showing') diff --git a/app/assets/javascripts/discourse/models/group.js.es6 b/app/assets/javascripts/discourse/models/group.js.es6 index 4566c154abc..299cda4b686 100644 --- a/app/assets/javascripts/discourse/models/group.js.es6 +++ b/app/assets/javascripts/discourse/models/group.js.es6 @@ -166,10 +166,6 @@ Group.reopenClass({ }); }, - findGroupCounts(name) { - return ajax("/groups/" + name + "/counts.json").then(result => Em.Object.create(result.counts)); - }, - find(name) { return ajax("/groups/" + name + ".json").then(result => Group.create(result.basic_group)); }, diff --git a/app/assets/javascripts/discourse/routes/group.js.es6 b/app/assets/javascripts/discourse/routes/group.js.es6 index 51724c18b45..3df20f794bf 100644 --- a/app/assets/javascripts/discourse/routes/group.js.es6 +++ b/app/assets/javascripts/discourse/routes/group.js.es6 @@ -14,12 +14,6 @@ export default Discourse.Route.extend({ return { name: model.get('name').toLowerCase() }; }, - afterModel(model) { - return Group.findGroupCounts(model.get('name')).then(counts => { - this.set('counts', counts); - }); - }, - setupController(controller, model) { controller.setProperties({ model, counts: this.get('counts') }); } diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index a39bdb3c98b..92dec3cce67 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -7,23 +7,6 @@ class GroupsController < ApplicationController render_serialized(find_group(:id), GroupShowSerializer, root: 'basic_group') end - def counts - group = find_group(:group_id) - - counts = { - posts: group.posts_for(guardian).count, - topics: group.posts_for(guardian).where(post_number: 1).count, - mentions: group.mentioned_posts_for(guardian).count, - members: group.users.count, - } - - if guardian.can_see_group_messages?(group) - counts[:messages] = group.messages_for(guardian).where(post_number: 1).count - end - - render json: { counts: counts } - end - def posts group = find_group(:group_id) posts = group.posts_for(guardian, params[:before_post_id]).limit(20) diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index b926e4d6c62..5cd791ba183 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -25,19 +25,6 @@ describe GroupsController do end end - describe "counts" do - it "returns counts if it can be seen" do - xhr :get, :counts, group_id: group.name - expect(response).to be_success - end - - it "returns no counts if it can not be seen" do - group.update_columns(visible: false) - xhr :get, :counts, group_id: group.name - expect(response).not_to be_success - end - end - describe "posts" do it "ensures the group can be seen" do Guardian.any_instance.expects(:can_see?).with(group).returns(false)