diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 100b41c9c3..4850337815 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -4,19 +4,29 @@ class Admin::DashboardController < Admin::BaseController require 'rexml/document' def index + t = Time.new + today = t.strftime("%Y-%m-%d 00:00") + + # Since last venue @newposts_count = Article.published_since(current_user.last_venue).count @newcomments_count = Feedback.published_since(current_user.last_venue).count - - @statposts = Article.published.count - @statcomments = Comment.not_spam.count - @presumedspam = Comment.presumed_spam.count - - @categories = Category.count - + + # Today + @statposts = Article.published.where("published_at > ?", today).count + @statsdrafts = Article.drafts.where("created_at > ?", today).count + @statspages = Page.where("published_at > ?", today).count + @statuses = Status.where("published_at > ?", today).count + @statuserposts = Article.published.where("published_at > ?", today).count(conditions: {user_id: current_user.id}) + + @statcomments = Comment.where("created_at > ?", today).count + @presumedspam = Comment.presumed_spam.where("created_at > ?", today).count + @confirmed = Comment.ham.where("created_at > ?", today).count + @unconfirmed = Comment.unconfirmed.where("created_at > ?", today).count + @comments = Comment.last_published @recent_posts = Article.published.limit(5) @bestof = Article.bestof - @statuserposts = Article.published.count(conditions: {user_id: current_user.id}) + @statspam = Comment.spam.count @inbound_links = inbound_links @publify_links = publify_dev diff --git a/app/models/article.rb b/app/models/article.rb index 0b93788b91..a57714a958 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -34,7 +34,6 @@ def ham def spam where(:state => ["presumed_spam", "spam"]) end - end with_options(:conditions => { :published => true }, :order => 'created_at ASC') do |this| diff --git a/app/models/comment.rb b/app/models/comment.rb index 3797503375..619637ae05 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -11,6 +11,9 @@ class Comment < Feedback scope :spam, lambda { where(state: 'spam') } scope :not_spam, lambda { where("state != 'spam'")} scope :presumed_spam, lambda { where(state: 'presumed_spam')} + scope :presumed_ham, lambda { where(state: 'presumed_ham')} + scope :ham, lambda { where(state: 'ham')} + scope :unconfirmed, lambda { where("state in (?, ?)", "presumed_spam", "presumed_ham")} scope :last_published, lambda { where(published:true).limit(5).order('created_at DESC') } def notify_user_via_email(user) diff --git a/app/views/admin/dashboard/_overview.html.erb b/app/views/admin/dashboard/_overview.html.erb index 3044071bcf..7895f7ecc2 100644 --- a/app/views/admin/dashboard/_overview.html.erb +++ b/app/views/admin/dashboard/_overview.html.erb @@ -1,4 +1,4 @@ -
<%= _("This place gives you a quick overview of what happens on your Publify blog and what you can do. Maybe will you want to %s", dashboard_action_links) %> diff --git a/app/views/admin/dashboard/_welcome.html.erb b/app/views/admin/dashboard/_welcome.html.erb index 16c849758c..944aa27326 100644 --- a/app/views/admin/dashboard/_welcome.html.erb +++ b/app/views/admin/dashboard/_welcome.html.erb @@ -1,24 +1,29 @@ -
<%= _("%d articles and %d comments were posted since your last connexion", @newposts_count, @newcomments_count) %>
+<%= _("You're running Publify %s", PUBLIFY_VERSION) %> <%= @version_message %>
-<%= _("%d articles and %d comments were posted since your last connexion", @newposts_count, @newcomments_count) %>
-<%= _("You're running Publify %s", PUBLIFY_VERSION) %> <%= @version_message %>
- - <% if current_user.profile.modules.include? :articles%> -<%= _("Content") %>
-<%= _("Feedback") %>
-<%= link_to(sprintf("%d %s", @statposts, pluralize(@statposts, _("articles"), _("article"), _("articles"))).html_safe, :controller => 'admin/content').html_safe %>
+<%= link_to(sprintf("%d %s", @statuserposts, _("articles writen by you")).html_safe, :controller => 'admin/content', "search[user_id]" => current_user.id).html_safe %>
+<%= link_to(sprintf("%d %s", @statsdrafts, pluralize(@statsdrafts, _("drafts"), _("draft"), _("drafts"))).html_safe, :controller => 'admin/content', "search[state]" => "drafts").html_safe %>
+<%= link_to(sprintf("%d %s", @statspages, pluralize(@statspages, _("pages"), _("page"), _("pages"))).html_safe, :controller => 'admin/pages').html_safe %>
+<%= link_to(sprintf("%d %s", @statuses, pluralize(@statspages, _("short statuses"), _("short status"), _("short statuses"))).html_safe, :controller => 'admin/statuses').html_safe %>
+ <% end %> +<%= link_to(sprintf("%d %s", @statcomments, _("comments")).html_safe, :controller => 'admin/feedback').html_safe %>
+<%= link_to(sprintf("%d %s", @confirmed, _("approved")).html_safe, :controller => 'admin/feedback', "ham" => "f").html_safe %>
+<%= link_to(sprintf("%d %s", @unconfirmed, _("unconfirmed")).html_safe, :controller => 'admin/feedback', "presumed_ham" => "f").html_safe %>
+<%= link_to(sprintf("%d %s", @statspam, _("spam")).html_safe, :controller => 'admin/feedback', "spam" => "f").html_safe %>
+ <% end %> +