add basic overview page to admin controller
This commit is contained in:
parent
46ef376bc1
commit
b1fc87ea30
4 changed files with 40 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
19
app/views/admins/stats.html.haml
Normal file
19
app/views/admins/stats.html.haml
Normal 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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue