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

[WIP] Design subscription stats output #5151

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/stats_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class StatsController < ApplicationController
def subscriptions
@tags = {}
@tags = {}
TagSelection.where(following: true).each do |tag|
@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}.map{|k,v| {k => v.map{|x| x.join("-")}}}
end

def range
Expand Down
29 changes: 27 additions & 2 deletions app/views/stats/subscriptions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,30 @@
<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>
<tr>
<thead>
<th>Subscriptions</th>
<th>Stats</th>
</thead>
</tr>
<% @tags.each do |map| %>
<% map.each do |subscriptions,stats| %>
<tr>
<tbody>
<td><%=subscriptions%></td>
<td>
<%stats.each do |stat| %>
<ul>
<%=stat%>
</ul>
<%end%>
</td>
</tbody>
</tr>
<% end %>
<% end %>
</table>
</div>