diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb index 1b7e858f8..bd2dc4d13 100644 --- a/app/controllers/admins_controller.rb +++ b/app/controllers/admins_controller.rb @@ -28,4 +28,12 @@ class AdminsController < ApplicationController flash[:notice] = "invitation sent to #{params[:identifier]}" redirect_to user_search_path end + + def stats + @popular_tags = ActsAsTaggableOn::Tagging.joins(:tag).limit(15).count(:group => :tag, :order => 'count(taggings.id) DESC') + @most_liked_posts = Post.where(:type => ['StatusMessage', 'ActivityStreams::Photo'], + :public => true).order('likes_count DESC').limit(15).all + @new_posts = Post.where(:type => ['StatusMessage','ActivityStreams::Photo'], + :public => true).order('created_at DESC').limit(15).all + end end diff --git a/app/views/admins/stats.html.haml b/app/views/admins/stats.html.haml new file mode 100644 index 000000000..565e7cfdf --- /dev/null +++ b/app/views/admins/stats.html.haml @@ -0,0 +1,19 @@ +.span-24.last + %h3 + = for tg in @popular_tags + = link_to tg, tags_path(tg) + +%br +%br + +.span-12 + %h3 + New public posts + .stream + = render 'shared/stream', :posts => @new_posts + +.span-12.last + %h3 + Most Liked + .stream + = render 'shared/stream', :posts => @most_liked_posts diff --git a/config/routes.rb b/config/routes.rb index e78d8b2ec..4cfdf5bcc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -83,6 +83,7 @@ Diaspora::Application.routes.draw do match 'user_search' => :user_search get 'admin_inviter' => :admin_inviter get 'add_invites' => :add_invites, :as => 'add_invites' + get 'stats' => :stats, :as => 'pod_stats' end resource :profile diff --git a/spec/controllers/admins_controller_spec.rb b/spec/controllers/admins_controller_spec.rb index 48348e0da..5b744d9c5 100644 --- a/spec/controllers/admins_controller_spec.rb +++ b/spec/controllers/admins_controller_spec.rb @@ -116,4 +116,16 @@ describe AdminsController do end end end + + describe '#stats' do + before do + AppConfig[:admins] = [@user.username] + end + + it 'succeeds and renders stats' do + get :stats + response.should be_success + response.should render_template(:stats) + end + end end