Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tag suggestions to show all relevant ones #7338

Merged
merged 16 commits into from
Apr 6, 2020
Merged
4 changes: 4 additions & 0 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ def self.graph_data(limit = 250)
end
end

def self.all_tags_by_popularity
Tag.all.order('count DESC').select { |tag| !(tag.name.include? ":") }.uniq(&:name).pluck(:name)
end

def subscription_graph(start = DateTime.now - 1.year, fin = DateTime.now)
date_hash = {}
week = start.to_date.step(fin.to_date, 7).count
Expand Down
2 changes: 1 addition & 1 deletion app/views/home/subscriptions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="form-group">
<div class="row">
<div class="col-md-7">
<input type="text" name="name" class="form-control" placeholder="<%= translation('home.subscriptions.enter_tags') %>" data-provide="typeahead" data-source='["balloon-mapping","thermal-flashlight","spectrometer"]' autocomplete="off" required="required">
<input type="text" name="name" class="form-control" placeholder="<%= translation('home.subscriptions.enter_tags') %>" data-provide="typeahead" data-source='<%= Tag.all_tags_by_popularity %>' autocomplete="off" required="required">
</div>
<div class="col-md-2 pl-md-1">
<button type="submit" class="btn btn-primary add-subscriptions"><i class="fa fa-plus fa fa-white"></i> <%= translation('home.subscriptions.add') %></button>
Expand Down