From 67a2b2598d0cb08e887f6841c5a80060ffe4617d Mon Sep 17 00:00:00 2001 From: Vikhyat Korrapati Date: Tue, 10 Jun 2014 06:53:18 +0530 Subject: [PATCH] Cosmetic changes. --- .../javascripts/admin/controllers/admin_badge_controller.js | 4 +++- app/assets/javascripts/discourse/models/user_badge.js | 4 ++-- app/assets/javascripts/discourse/routes/user_badges_route.js | 2 +- app/controllers/user_badges_controller.rb | 2 +- spec/controllers/user_badges_controller_spec.rb | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin_badge_controller.js b/app/assets/javascripts/admin/controllers/admin_badge_controller.js index cdc06cfe74c..3fb21eab684 100644 --- a/app/assets/javascripts/admin/controllers/admin_badge_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_badge_controller.js @@ -8,6 +8,8 @@ @module Discourse **/ +var RESERVED_BADGE_COUNT = 100; + Discourse.AdminBadgeController = Discourse.ObjectController.extend({ /** Whether this badge has been selected. @@ -31,5 +33,5 @@ Discourse.AdminBadgeController = Discourse.ObjectController.extend({ @property readOnly @type {Boolean} **/ - readOnly: Ember.computed.lt('model.id', 100) + readOnly: Ember.computed.lt('model.id', RESERVED_BADGE_COUNT) }); diff --git a/app/assets/javascripts/discourse/models/user_badge.js b/app/assets/javascripts/discourse/models/user_badge.js index a7005341c0e..410dbd4c880 100644 --- a/app/assets/javascripts/discourse/models/user_badge.js +++ b/app/assets/javascripts/discourse/models/user_badge.js @@ -84,8 +84,8 @@ Discourse.UserBadge.reopenClass({ **/ findByUsername: function(username, options) { var url = "/user_badges.json?username=" + username; - if (options && options.aggregated) { - url += "&aggregated=true"; + if (options && options.grouped) { + url += "&grouped=true"; } return Discourse.ajax(url).then(function(json) { return Discourse.UserBadge.createFromJson(json); diff --git a/app/assets/javascripts/discourse/routes/user_badges_route.js b/app/assets/javascripts/discourse/routes/user_badges_route.js index c5ce95d1c6a..b6717117fa1 100644 --- a/app/assets/javascripts/discourse/routes/user_badges_route.js +++ b/app/assets/javascripts/discourse/routes/user_badges_route.js @@ -8,7 +8,7 @@ **/ Discourse.UserBadgesRoute = Discourse.Route.extend({ model: function() { - return Discourse.UserBadge.findByUsername(this.modelFor('user').get('username_lower'), {aggregated: true}); + return Discourse.UserBadge.findByUsername(this.modelFor('user').get('username_lower'), {grouped: true}); }, setupController: function(controller, model) { diff --git a/app/controllers/user_badges_controller.rb b/app/controllers/user_badges_controller.rb index 373234bb5ba..e2f96d6ec58 100644 --- a/app/controllers/user_badges_controller.rb +++ b/app/controllers/user_badges_controller.rb @@ -16,7 +16,7 @@ class UserBadgesController < ApplicationController user_badges = user_badges.includes(:user, :granted_by, badge: :badge_type) - if params[:aggregated] + if params[:grouped] user_badges = user_badges.group(:badge_id).select(UserBadge.attribute_names.map {|x| "MAX(#{x}) as #{x}" }, 'COUNT(*) as count') end diff --git a/spec/controllers/user_badges_controller_spec.rb b/spec/controllers/user_badges_controller_spec.rb index a26b52650e6..d93e990ea84 100644 --- a/spec/controllers/user_badges_controller_spec.rb +++ b/spec/controllers/user_badges_controller_spec.rb @@ -28,7 +28,7 @@ describe UserBadgesController do end it 'includes counts when passed the aggregate argument' do - xhr :get, :index, username: user.username, aggregated: true + xhr :get, :index, username: user.username, grouped: true response.status.should == 200 parsed = JSON.parse(response.body)