File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #This is the 'admins' controller
2+
3+ # Show how many users there are
4+ get '/admin' do
5+ admin_only!
6+ #get usercount
7+ @usercount = Hacker . all . length
8+ today = Date . today
9+ @newusers = Hacker . all ( :created_at => { '$gt' => today . to_time , '$lt' => ( today + 1 . day ) . to_time } ) . length
10+ @newusernames = Hacker . all ( :created_at => { '$gt' => today . to_time , '$lt' => ( today + 1 . day ) . to_time } )
11+ @forumposts = Discussion . all ( :created_at => { '$gt' => today . to_time , '$lt' => ( today + 1 . day ) . to_time } ) . length
12+ @postlinks = Discussion . all ( :created_at => { '$gt' => today . to_time , '$lt' => ( today + 1 . day ) . to_time } )
13+ @forumreplies = Discussion . all ( :updated_at => { '$gt' => today . to_time , '$lt' => ( today + 1 . day ) . to_time } ) . length
14+
15+ haml :"admin/index"
16+ end
17+
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ class Hacker
66
77 #we're storing a unique username
88 key :username , String , :unique => true
9+ timestamps!
910 #and a unique email
1011 key :email , String , :unique => true
1112
Original file line number Diff line number Diff line change 1+ %h1 = current_user.username + " 's admin page"
2+ %img {:src => current_user.gravatar_url}
3+
4+ %p Total Hacker Count: #{@usercount}
5+
6+ %p New Users Today: #{@newusers}
7+ %ul
8+ - @newusernames.each do |name|
9+ %li
10+ %a {:href => " /hackers/#{ name.username } " }= name.username
11+
12+ %p New Forum Discussions: #{@forumposts}
13+ %ul
14+ - @postlinks.each do |postlink|
15+ %li
16+ %a {:href => " /forums/#{ postlink.title } " }= postlink.title
17+
18+ %p New Forum Replies: #{@forumreplies}
19+ %ul
20+ - @postlinks.each do |replylink|
21+ %li
22+ %a {:href => " /forums/#{ replylink.title } /#{ replylink.replies.title } " }= replylink.slug
23+
24+
You can’t perform that action at this time.
0 commit comments