diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-03-20 11:00:31 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-03-20 11:00:31 -0400 |
| commit | 5462a1e56abf70486dc59593dde6ecb95a072026 (patch) | |
| tree | 3e956e0ca3bfbf773af3a9dd303cb4743615fe67 /app | |
| parent | 2e1365d37bddf787c7089126c1a5ff1c623ab0e2 (diff) | |
| download | thoughts-5462a1e56abf70486dc59593dde6ecb95a072026.tar.gz thoughts-5462a1e56abf70486dc59593dde6ecb95a072026.tar.bz2 thoughts-5462a1e56abf70486dc59593dde6ecb95a072026.zip | |
Added some admin dashboard stats
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/comments_controller.rb | 2 | ||||
| -rw-r--r-- | app/models/global.rb | 20 | ||||
| -rw-r--r-- | app/views/admin/dashboard/index.html.haml | 20 |
3 files changed, 41 insertions, 1 deletions
| diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 368f587..b305d0a 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb | |||
| @@ -35,6 +35,8 @@ class CommentsController < ApplicationController | |||
| 35 | if is_blatant | 35 | if is_blatant |
| 36 | # I am lying. | 36 | # I am lying. |
| 37 | flash.notice = "Comment submitted successfully! It will need to be moderated before it shows up on the blog." | 37 | flash.notice = "Comment submitted successfully! It will need to be moderated before it shows up on the blog." |
| 38 | |||
| 39 | Global.increment_filtered_comments | ||
| 38 | else | 40 | else |
| 39 | if is_spam | 41 | if is_spam |
| 40 | @comment.status = :pending | 42 | @comment.status = :pending |
| diff --git a/app/models/global.rb b/app/models/global.rb new file mode 100644 index 0000000..7c7d6d4 --- /dev/null +++ b/app/models/global.rb | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | class Global < ApplicationRecord | ||
| 2 | def self.get_filtered_comments | ||
| 3 | row = find_by_key("filtered_comments") | ||
| 4 | if row | ||
| 5 | row[:int_value] | ||
| 6 | else | ||
| 7 | 0 | ||
| 8 | end | ||
| 9 | end | ||
| 10 | |||
| 11 | def self.increment_filtered_comments | ||
| 12 | row = find_by_key("filtered_comments") | ||
| 13 | if row | ||
| 14 | row.int_value += 1 | ||
| 15 | row.save | ||
| 16 | else | ||
| 17 | create(key: "filtered_comments", int_value: 1) | ||
| 18 | end | ||
| 19 | end | ||
| 20 | end | ||
| diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index eaac627..254107c 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml | |||
| @@ -1 +1,19 @@ | |||
| 1 | Welcome to the the ubiquitous administration panel! | 1 | %p Welcome to the the ubiquitous administration panel! |
| 2 | %p Stats: | ||
| 3 | %ul | ||
| 4 | %li | ||
| 5 | %strong Blog posts: | ||
| 6 | = Blog.count | ||
| 7 | %li | ||
| 8 | %strong Approved comments: | ||
| 9 | = Comment.where(status: :published).count | ||
| 10 | %li | ||
| 11 | %strong Filtered comments: | ||
| 12 | = Global.get_filtered_comments | ||
| 13 | %li | ||
| 14 | %strong Quotes: | ||
| 15 | = Quote.count | ||
| 16 | %li | ||
| 17 | %strong Votes: | ||
| 18 | = Vote.count | ||
| 19 | (+#{Vote.where(upvote: true).count} / -#{Vote.where(upvote: false).count}) | ||
