From f775f6f7694541c7d0e461da37b732e49a1f319c Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 3 Nov 2022 18:46:12 -0700 Subject: [PATCH 1/5] fix bug preventing the deletion of documents in folders --- app/controllers/folders_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb index 715b90ee..209fb60e 100644 --- a/app/controllers/folders_controller.rb +++ b/app/controllers/folders_controller.rb @@ -20,7 +20,7 @@ class FoldersController < ApplicationController Document.where(folder_id: @folder.id).update_all(folder_id: nil) # Relocate all child folders in this folder to the root "folder" - Folder.where(parent_folder_id: @folder.id).update_all(folder_id: nil) + Folder.where(parent_folder_id: @folder.id).update_all(parent_folder_id: nil) @folder.destroy! redirect_to(documents_path, notice: "Folder #{@folder.title} deleted!") From cb6216aec9a6c17014766bfa58324342a0ebac76 Mon Sep 17 00:00:00 2001 From: drusepth Date: Fri, 4 Nov 2022 00:26:11 -0700 Subject: [PATCH 2/5] highlight active threads on dashboard --- app/controllers/main_controller.rb | 11 +++++++++++ app/views/main/dashboard.html.erb | 28 ++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 3c44b5cd..7c100ac5 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -25,6 +25,17 @@ class MainController < ApplicationController def dashboard @page_title = "My notebook" + messageboard_ids_to_exclude = [38, 26, 31, 32, 30, 33, 27] + most_recent_posts = Thredded::Post.where.not(messageboard_id: messageboard_ids_to_exclude) + .where(moderation_state: "approved") + .order('id DESC') + .limit(300) + .shuffle + .first(3) + @most_recent_threads = Thredded::Topic.where(id: most_recent_posts.pluck(:postable_id)) + .where(moderation_state: "approved") + .includes(:posts, :messageboard) + set_questionable_content # for questions end diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index af02bd74..6568fbe9 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -186,10 +186,8 @@ <% end %>
Create something new
- <% shown_creatures = false %> <% @activated_content_types.sample(3).each do |type| %> <% klass = content_class_from_name(type) %> - <% shown_creatures = true if type == 'Creature' %>
<%= link_to send("new_#{type.downcase}_path"), class: "white-text", style: 'width: 100%' do %>
@@ -212,6 +210,32 @@
<% end %> +
Join discussions
+ <% @most_recent_threads.each do |topic| %> +
+ <%= link_to topic, class: "white-text", style: 'width: 100%' do %> +
+
+ forum + + <%= topic.title %> + + <%= pluralize topic.posts.count, 'post' %> + +
+ + in <%= topic.messageboard.name %> + +
+
+
+ <% end %> +
+ <% end %> +
+ <%= link_to 'see all', thredded_path, class: 'right' %> +
+
From 00953ad85cfd16c4757b23273e928539b4cb960d Mon Sep 17 00:00:00 2001 From: drusepth Date: Sat, 5 Nov 2022 23:24:42 -0700 Subject: [PATCH 3/5] make government pages free to create --- app/models/page_types/government.rb | 2 +- app/views/main/dashboard.html.erb | 2 ++ .../notice_dismissal/messages/_17.html.erb | 18 ++++++++++++++++++ config/initializers/promos.rb | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 app/views/notice_dismissal/messages/_17.html.erb diff --git a/app/models/page_types/government.rb b/app/models/page_types/government.rb index fc3e89d2..686a6af8 100644 --- a/app/models/page_types/government.rb +++ b/app/models/page_types/government.rb @@ -10,7 +10,7 @@ class Government < ApplicationRecord include Serendipitous::Concern include Authority::Abilities - self.authorizer_name = 'ExtendedContentAuthorizer' + self.authorizer_name = Date.current <= 'November 17, 2022'.to_date ? 'CoreContentAuthorizer' : 'ExtendedContentAuthorizer' relates :leaders, with: :government_leaders relates :groups, with: :government_groups diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index 6568fbe9..d4ba1d2b 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -155,6 +155,8 @@ <% end %> + <%= render partial: 'notice_dismissal/messages/17' %> +
<% if @recently_edited_pages.any? %>
diff --git a/app/views/notice_dismissal/messages/_17.html.erb b/app/views/notice_dismissal/messages/_17.html.erb new file mode 100644 index 00000000..4dcb5109 --- /dev/null +++ b/app/views/notice_dismissal/messages/_17.html.erb @@ -0,0 +1,18 @@ +<% if Date.current <= 'November 9, 2022'.to_date && show_notice?(id: 6) %> +
+
+ Free for everyone +
+ <%= link_to main_app.customization_content_types_path do %> +
+
+ <%= Government.icon %> +
+ Government pages are free to create for all users until November 17.
+ Just turn them on and start creating! +
+
+
+ <% end %> +
+<% end %> \ No newline at end of file diff --git a/config/initializers/promos.rb b/config/initializers/promos.rb index b1b5cb9b..0548fe61 100644 --- a/config/initializers/promos.rb +++ b/config/initializers/promos.rb @@ -13,4 +13,4 @@ if Date.current >= 'March 1, 2020'.to_date Rails.application.config.content_types[:free] << Lore Rails.application.config.content_types[:premium] -= [Lore] end -end +end \ No newline at end of file From 69e6505ef1e01b81d49d2f8b52dc24314971140f Mon Sep 17 00:00:00 2001 From: drusepth Date: Fri, 18 Nov 2022 19:10:36 -0800 Subject: [PATCH 4/5] admin graphs refactoring --- app/controllers/admin_controller.rb | 2 +- app/views/admin/dashboard.html.erb | 73 +++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7b6e7f4a..7b6fe533 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -6,7 +6,7 @@ class AdminController < ApplicationController before_action :require_admin_access, unless: -> { Rails.env.development? } def dashboard - @reports = EndOfDayAnalyticsReport.order('day DESC').limit(90) + @reports = EndOfDayAnalyticsReport.order('day DESC') end def content_type diff --git a/app/views/admin/dashboard.html.erb b/app/views/admin/dashboard.html.erb index 00d8f498..3d30953f 100644 --- a/app/views/admin/dashboard.html.erb +++ b/app/views/admin/dashboard.html.erb @@ -5,10 +5,10 @@
90-day signups - <%= number_with_delimiter User.last.id %> total + <%= number_with_delimiter User.last.id %> total users
- <%= area_chart @reports.pluck(:day, :user_signups), colors: ['#2196F3'] %> + <%= area_chart @reports.limit(90).pluck(:day, :user_signups), colors: ['#2196F3'] %>
@@ -16,18 +16,23 @@
- Monthly subscriptions + 90-day monthly subscriptions - <%= number_with_delimiter User.where(selected_billing_plan_id: 4).count %> total + <%= number_with_delimiter User.where(selected_billing_plan_id: 4).count %> current total
<%= area_chart [ - { name: 'Started subscriptions', data: @reports.pluck(:day, :new_monthly_subscriptions) }, - { name: 'Ended subscriptions', data: @reports.pluck(:day, :ended_monthly_subscriptions) } + { name: 'Started subscriptions', data: @reports.limit(90).pluck(:day, :new_monthly_subscriptions) }, + { name: 'Ended subscriptions', data: @reports.limit(90).pluck(:day, :ended_monthly_subscriptions) } ], colors: ['#2196F3'] %> +
+ 90-day net: + <%= sprintf "%+d", @reports.limit(90).sum(:new_monthly_subscriptions) - @reports.limit(90).sum(:ended_monthly_subscriptions) %> + subscriptions +
@@ -35,16 +40,23 @@
- Trimonthly subscriptons + 90-day trimonthly subscriptons - <%= number_with_delimiter User.where(selected_billing_plan_id: 5).count %> total + <%= number_with_delimiter User.where(selected_billing_plan_id: 5).count %> current total
- <%= area_chart [ - { name: 'Started subscriptions', data: @reports.pluck(:day, :new_trimonthly_subscriptions) }, - { name: 'Ended subscriptions', data: @reports.pluck(:day, :ended_trimonthly_subscriptions) } + <%= + area_chart [ + { name: 'Started subscriptions', data: @reports.limit(90).pluck(:day, :new_trimonthly_subscriptions) }, + { name: 'Ended subscriptions', data: @reports.limit(90).pluck(:day, :ended_trimonthly_subscriptions) } ], - colors: ['#2196F3'] %> + colors: ['#2196F3'] + %> +
+ 90-day net: + <%= sprintf "%+d", @reports.limit(90).sum(:new_trimonthly_subscriptions) - @reports.limit(90).sum(:ended_trimonthly_subscriptions) %> + subscriptions +
@@ -52,16 +64,23 @@
- Annual subscriptions + 90-day annual subscriptions - <%= number_with_delimiter User.where(selected_billing_plan_id: 6).count %> total + <%= number_with_delimiter User.where(selected_billing_plan_id: 6).count %> current total
- <%= area_chart [ - { name: 'Started subscriptions', data: @reports.pluck(:day, :new_annual_subscriptions) }, - { name: 'Ended subscriptions', data: @reports.pluck(:day, :ended_annual_subscriptions) } + <%= + area_chart [ + { name: 'Started subscriptions', data: @reports.limit(90).pluck(:day, :new_annual_subscriptions) }, + { name: 'Ended subscriptions', data: @reports.limit(90).pluck(:day, :ended_annual_subscriptions) } ], - colors: ['#2196F3'] %> + colors: ['#2196F3'] + %> +
+ 90-day net: + <%= sprintf "%+d", @reports.limit(90).sum(:new_annual_subscriptions) - @reports.limit(90).sum(:ended_annual_subscriptions) %> + subscriptions +
@@ -71,10 +90,24 @@
- New <%= content_type.name.pluralize %> + New <%= content_type.name.pluralize %> each day <%= number_with_delimiter content_type.last.id %> total
- <%= area_chart @reports.pluck(:day, "#{content_type.name.downcase.pluralize}_created"), colors: [content_type.hex_color] %> + <%= + area_chart @reports.order("#{content_type.name.downcase.pluralize}_created DESC") + .pluck(:day, "#{content_type.name.downcase.pluralize}_created") + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += count } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [content_type.hex_color] + %>
From e5290b96c102b844443bb9b63631bbee342a9104 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 22 Nov 2022 13:36:24 -0800 Subject: [PATCH 5/5] wrap up admin panel work --- app/views/admin/dashboard.html.erb | 200 ++++++++++++++++++++++++++--- 1 file changed, 184 insertions(+), 16 deletions(-) diff --git a/app/views/admin/dashboard.html.erb b/app/views/admin/dashboard.html.erb index 3d30953f..e393baee 100644 --- a/app/views/admin/dashboard.html.erb +++ b/app/views/admin/dashboard.html.erb @@ -94,12 +94,11 @@ <%= number_with_delimiter content_type.last.id %> total <%= - area_chart @reports.order("#{content_type.name.downcase.pluralize}_created DESC") - .pluck(:day, "#{content_type.name.downcase.pluralize}_created") + area_chart @reports.pluck(:day, "#{content_type.name.downcase.pluralize}_created") .group_by { |date, total| date.year } .map { |year, data| totals_per_month = Hash.new(0) - data.each { |date, count| totals_per_month[date.strftime("%b")] += count } + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } { name: year, @@ -119,7 +118,20 @@ New timelines <%= number_with_delimiter Timeline.last.id %> total - <%= area_chart @reports.pluck(:day, :timelines_created), colors: [Timeline.hex_color] %> + <%= + area_chart @reports.pluck(:day, :timelines_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [Timeline.hex_color] + %> @@ -131,7 +143,20 @@ New stream shares <%= number_with_delimiter ContentPageShare.last.id %> total - <%= area_chart @reports.pluck(:day, :stream_shares_created), colors: [ContentPageShare.hex_color] %> + <%= + area_chart @reports.pluck(:day, :stream_shares_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [ContentPageShare.hex_color] + %> @@ -141,7 +166,20 @@
New stream comments
- <%= area_chart @reports.pluck(:day, :stream_comments), colors: [ContentPageShare.hex_color] %> + <%= + area_chart @reports.pluck(:day, :stream_comments) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [ContentPageShare.hex_color] + %> @@ -153,7 +191,20 @@ New collections <%= number_with_delimiter PageCollection.last.id %> total - <%= area_chart @reports.pluck(:day, :collections_created), colors: [PageCollection.hex_color] %> + <%= + area_chart @reports.pluck(:day, :collections_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [PageCollection.hex_color] + %> @@ -164,7 +215,20 @@ New collection submissions <%= number_with_delimiter PageCollectionSubmission.last.id %> total - <%= area_chart @reports.pluck(:day, :collection_submissions_created), colors: [PageCollection.hex_color] %> + <%= + area_chart @reports.pluck(:day, :collection_submissions_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [PageCollection.hex_color] + %> @@ -176,7 +240,20 @@ New discussion threads <%= number_with_delimiter Thredded::Topic.last.id %> total - <%= area_chart @reports.pluck(:day, :thredded_threads_created), colors: ['#2196F3'] %> + <%= + area_chart @reports.pluck(:day, :thredded_threads_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: ['#2196F3'] + %> @@ -187,7 +264,20 @@ New discussion replies <%= number_with_delimiter Thredded::Post.last.id %> total - <%= area_chart @reports.pluck(:day, :thredded_replies_created), colors: ['#2196F3'] %> + <%= + area_chart @reports.pluck(:day, :thredded_replies_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: ['#2196F3'] + %> @@ -199,7 +289,20 @@ New private discussions <%= number_with_delimiter Thredded::PrivateTopic.last.id %> total - <%= area_chart @reports.pluck(:day, :thredded_private_messages_created), colors: ['#2196F3'] %> + <%= + area_chart @reports.pluck(:day, :thredded_private_messages_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: ['#2196F3'] + %> @@ -210,7 +313,20 @@ New private replies <%= number_with_delimiter Thredded::PrivatePost.last.id %> total - <%= area_chart @reports.pluck(:day, :thredded_private_replies_created), colors: ['#2196F3'] %> + <%= + area_chart @reports.pluck(:day, :thredded_private_replies_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: ['#2196F3'] + %> @@ -222,7 +338,20 @@ New documents <%= number_with_delimiter Document.last.id %> total - <%= area_chart @reports.pluck(:day, :documents_created), colors: [Document.hex_color] %> + <%= + area_chart @reports.pluck(:day, :documents_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [Document.hex_color] + %> @@ -232,7 +361,20 @@
Updated documents
- <%= area_chart @reports.pluck(:day, :documents_edited), colors: [Document.hex_color] %> + <%= + area_chart @reports.pluck(:day, :documents_edited) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [Document.hex_color] + %> @@ -243,7 +385,20 @@ Document revisions <%= number_with_delimiter DocumentRevision.last.id %> total - <%= area_chart @reports.pluck(:day, :document_revisions_created), colors: [Document.hex_color] %> + <%= + area_chart @reports.pluck(:day, :document_revisions_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [Document.hex_color] + %> @@ -254,7 +409,20 @@ New document analyses <%= number_with_delimiter DocumentAnalysis.last.id %> total - <%= area_chart @reports.pluck(:day, :document_analyses_created), colors: ['#2196F3'] %> + <%= + area_chart @reports.pluck(:day, :document_analyses_created) + .group_by { |date, total| date.year } + .map { |year, data| + totals_per_month = Hash.new(0) + data.each { |date, count| totals_per_month[date.strftime("%b")] += (count || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [Document.hex_color] + %>