Skip to content

Commit

Permalink
stats subscriptions rusers.status = 1, 4
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren authored Jun 3, 2020
1 parent 9b469ee commit 8b0b3d5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions app/controllers/stats_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
class StatsController < ApplicationController
def subscriptions
@tags = TagSelection
.select("DISTINCT tag_selections.tid, tag_selections.user_id")
.where(following: true)
.joins("INNER JOIN community_tags ON community_tags.tid = tag_selections.tid")
.joins("INNER JOIN term_data ON term_data.tid = community_tags.tid")
.group("term_data.name")
.count
@tags = Rails.cache.fetch("stats-subscriptions-query", expires_in: 24.hours) do
TagSelection
.select("DISTINCT tag_selections.tid, tag_selections.user_id")
.where(following: true)
.joins("INNER JOIN community_tags ON community_tags.tid = tag_selections.tid")
.joins("INNER JOIN term_data ON term_data.tid = community_tags.tid")
.group("term_data.name")
.joins("INNER JOIN rusers ON rusers.id = tag_selections.user_id")
.where("rusers.status = 1 OR rusers.status = 4")
.count
end
@tags = @tags.group_by { |_k, v| v / 10 }.sort_by { |k, _v| -k }
end

Expand Down

0 comments on commit 8b0b3d5

Please sign in to comment.