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
21 changes: 20 additions & 1 deletion app/views/stats/subscriptions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
<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>
<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>
<% tags.each do |tag| %>
<td><%= tag[0]%>:<%=tag[1] %></td>
Copy link
Member

Choose a reason for hiding this comment

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

Oh, aha - yes, so instead of the <td> we need to also use <p> tags - and the <td> tags should go outside the each loop. That way the whole collection will be in a single table cell, but each tag will be in its own paragraph (on its own line). Make sense?

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 though long it's clear. and more readable too.

ptags

Copy link
Member

Choose a reason for hiding this comment

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

Great! Actually let's tackle a few more things in a follow-up PR:

  1. let's sort this DESCENDING or desc so we start with the most-used tags
  2. let's hide anything more than 25 results and show a "View all" link to show them?
  3. let's make the tag names into links that go to /tag/TAGNAME

and we can do more! This is a great start!

<%end%>
</tbody>
</tr>
<% end %>
</table>
</div>