Remove old Dashboard Pro code (#3161)

This commit is contained in:
rhymes 2019-06-14 19:31:22 +02:00 committed by Mac Siri
parent aa29a5cb55
commit 272e032997
3 changed files with 9 additions and 86 deletions

View file

@ -46,16 +46,15 @@ class DashboardsController < ApplicationController
end
def pro
user_or_org = if params[:org_id]
org = Organization.find_by(id: params[:org_id])
authorize org, :pro_org_user?
org
else
authorize current_user, :pro_user?
current_user
end
@user_or_org = if params[:org_id]
org = Organization.find_by(id: params[:org_id])
authorize org, :pro_org_user?
org
else
authorize current_user, :pro_user?
current_user
end
@organizations = current_user.member_organizations
@dashboard = Dashboard::Pro.new(user_or_org)
end
private

View file

@ -1,76 +0,0 @@
module Dashboard
class Pro
attr_reader :user_or_org
def initialize(user_or_org)
@user_or_org = user_or_org
end
def user_or_org_article_ids
@user_or_org_article_ids ||=
Article.published.where("#{user_or_org.class.name.downcase}_id" => user_or_org.id).
pluck(:id)
end
def this_week_reactions
ChartDecorator.decorate(Reaction.where(reactable_id: user_or_org_article_ids, reactable_type: "Article").where("created_at > ?", 1.week.ago).order("created_at ASC"))
end
def this_week_reactions_count
this_week_reactions.size
end
def last_week_reactions_count
Reaction.where(reactable_id: user_or_org_article_ids, reactable_type: "Article").where("created_at > ? AND created_at < ?", 2.weeks.ago, 1.week.ago).size
end
def this_month_reactions_count
Reaction.where(reactable_id: user_or_org_article_ids, reactable_type: "Article").where("created_at > ?", 1.month.ago).size
end
def last_month_reactions_count
Reaction.where(reactable_id: user_or_org_article_ids, reactable_type: "Article").where("created_at > ? AND created_at < ?", 2.months.ago, 1.month.ago).size
end
def this_week_comments
ChartDecorator.decorate(Comment.where(commentable_id: user_or_org_article_ids, commentable_type: "Article").where("created_at > ?", 1.week.ago))
end
def this_week_comments_count
this_week_comments.size
end
def last_week_comments_count
Comment.where(commentable_id: user_or_org_article_ids, commentable_type: "Article").where("created_at > ? AND created_at < ?", 2.weeks.ago, 1.week.ago).size
end
def this_month_comments_count
Comment.where(commentable_id: user_or_org_article_ids, commentable_type: "Article").where("created_at > ?", 1.month.ago).size
end
def last_month_comments_count
Comment.where(commentable_id: user_or_org_article_ids, commentable_type: "Article").where("created_at > ? AND created_at < ?", 2.months.ago, 1.month.ago).size
end
def this_week_followers_count
Follow.where(followable_id: user_or_org.id, followable_type: user_or_org.class.name).where("created_at > ?", 1.week.ago).size
end
def last_week_followers_count
Follow.where(followable_id: user_or_org.id, followable_type: user_or_org.class.name).where("created_at > ? AND created_at < ?", 2.weeks.ago, 1.week.ago).size
end
def this_month_followers_count
Follow.where(followable_id: user_or_org.id, followable_type: user_or_org.class.name).where("created_at > ?", 1.month.ago).size
end
def last_month_followers_count
Follow.where(followable_id: user_or_org.id, followable_type: user_or_org.class.name).where("created_at > ? AND created_at < ?", 2.months.ago, 1.month.ago).size
end
def reactors
User.where(id: Reaction.where(reactable_id: user_or_org_article_ids, reactable_type: "Article").
order("created_at DESC").limit(100).pluck(:user_id))
end
end
end

View file

@ -17,7 +17,7 @@
<% end %>
<section class="header-card card">
<h1 class="pro-header">Pro Dashboard for <%= @dashboard.user_or_org.name %></h1>
<h1 class="pro-header">Pro Dashboard for <%= @user_or_org.name %></h1>
<p>Welcome to the Pro Dashboard which shows in-depth user metrics so that authors can make data-driven decisions about the developer ecosystem.</p>
<p>This dashboard will highlight deep insights especially relevant to developer relations authors and serious bloggers.</p>
</section>