Skip to content

Commit

Permalink
Merge CDB-1442 into release/2.13.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kart Ofante committed May 8, 2014
2 parents 9785e80 + 450ee7d commit 5175fa2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/controllers/admin/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def datasets
viewed_user = User.where(username: user.strip.downcase).first
return render_404 if viewed_user.nil?

@tags = viewed_user.map_tags
@tags = viewed_user.map_tags.sort_by{ |m| m.downcase }

@username = viewed_user.username
@avatar_url = viewed_user.gravatar(request.protocol)
Expand Down Expand Up @@ -50,7 +50,7 @@ def datasets
title: dataset.name,
description: dataset.description,
updated_at: dataset.updated_at,
tags: dataset.tags
tags: dataset.tags.sort_by{ |m| m.downcase }
}
)
end
Expand All @@ -67,7 +67,7 @@ def public
viewed_user = User.where(username: user.strip.downcase).first
return render_404 if viewed_user.nil?

@tags = viewed_user.tags
@tags = viewed_user.map_tags.sort_by{ |m| m.downcase }

@username = viewed_user.username
@avatar_url = viewed_user.gravatar(request.protocol)
Expand Down
7 changes: 6 additions & 1 deletion app/models/visualization/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def count(params={})
SELECT name, count(*) as count
FROM tags
GROUP BY name
ORDER BY count(*)
#{order_from(params)}
}, map_ids_for(user), types_from(params), limit_from(params)
).all.map(&:values)
end #count
Expand All @@ -48,6 +48,11 @@ def map_ids_for(user)
user.maps.map(&:id)
end #map_ids

def order_from(params={})
order = params.fetch(:order, nil)
(order.nil? || order.empty?) ? ' ORDER BY count(*) ' : " ORDER BY #{order} "
end #order_from

def privacy_from(params={})
privacy = params.fetch(:privacy, nil)
(privacy.nil? || privacy.empty?) ? Member::PRIVACY_VALUES : [privacy]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ cdb.admin.TagDropdown = cdb.ui.common.Dropdown.extend({
var self = this;
this.tags.fetch({
data: {
order: "name",
type: self.model.get("type")
},
success: function() {
Expand Down

0 comments on commit 5175fa2

Please sign in to comment.