add basic overview page to admin controller

This commit is contained in:
danielgrippi 2011-07-06 19:07:44 -07:00
parent 46ef376bc1
commit b1fc87ea30
4 changed files with 40 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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