Sha256: 7310e814405fda1c72269552a4a8652dff330e75a7d30013da9c08e5c67ae8be
Contents?: true
Size: 1.42 KB
Versions: 6
Compression:
Stored size: 1.42 KB
Contents
class Admin::DashboardController < Admin::BaseController def index comments lastposts popular statistics end private def statistics @statposts = Article.count_published_articles @statuserposts = current_user.articles.size @statcomments = Comment.count(:all, :conditions => "state != 'spam'") @statspam = Comment.count(:all, :conditions => { :state => 'spam' }) end def comments @comments ||= Comment.find(:all, :limit => 10, :conditions => ['published = ?', true], :order => 'created_at DESC') end def lastposts @recent_posts = Article.find(:all, :conditions => ["published = ?", true], :order => 'published_at DESC', :limit => 10) end def popular @bestof = Article.find(:all, :select => 'contents.*, comment_counts.count AS comment_count', :from => "contents, (SELECT feedback.article_id AS article_id, COUNT(feedback.id) as count FROM feedback GROUP BY feedback.article_id ORDER BY count DESC LIMIT 9) AS comment_counts", :conditions => ['comment_counts.article_id = contents.id AND published = ?', true], :order => 'comment_counts.count DESC', :limit => 9) end end
Version data entries
6 entries across 6 versions & 1 rubygems