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

group subscription tags with number of subscribers #5224

Merged
2 changes: 1 addition & 1 deletion app/controllers/stats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def subscriptions
@tags[tag.tagname] = @tags[tag.tagname] || 0
@tags[tag.tagname] += 1
end
render plain: @tags.inspect, status: 200
@tags = @tags.group_by { |_k, v| v / 10 }
end

def range
Expand Down
34 changes: 30 additions & 4 deletions app/views/stats/subscriptions.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
<div class="col-md-3">
<h4> About this page </h4>
<p> People subscribe to tags so that they can be updated when a research is posted with the tag they are subscribed to. This page shows the number of subscriptions and subscription rates on different tags. </p>
<h4> About this page </h4>
<p> People subscribe to tags so that they can be updated when a research is posted with the tag they are subscribed to. This page shows the number of subscriptions and subscription rates on different tags. </p>
</div>
<div class="col-md-8 col-md-offset-1">
<h2>Subscriptions</h2>
</div>
<h2>Subscriptions</h2>
<table class="table inline-grid">
<tr>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge deal, but would you mind using just 2 spaces for indents? We've tried to standardize a bit on this to help keep our code tidier. Thanks, and sorry for the minute details! 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes of course. sorry I switched to a new editor that I'm still finding my way around. I'll fix that.

<thead>
<th>Subscriptions</th>
<th>Tags</th>
</thead>
</tr>
<% @tags.each do |range,tags| %>
<tr>
<tbody>
<td>
<%= range * 10 %> -
<%= range * 10 + 9 %>
</td>
<td>
<% tags.each do |tag| %>
<p>
<%= tag[0]%>:
<%=tag[1] %>
</p>
<%end%>
</td>
</tbody>
</tr>
<% end %>
</table>
</div>