Skip to content

Commit

Permalink
group subscription tags with number of subscribers (publiclab#5224)
Browse files Browse the repository at this point in the history
* group tags with number of subscribers

* cleanup

* fix codeclimate errors

* refactoring the subscriber count range and stats display

* fix codeclimate failing lint test

* fix indent on stats view
  • Loading branch information
GettyOrawo authored and icarito committed Apr 9, 2019
1 parent 297909b commit 737951f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
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>
<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>

0 comments on commit 737951f

Please sign in to comment.