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/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!") diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index d1e59fca..4d501505 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -33,6 +33,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/models/page_types/government.rb b/app/models/page_types/government.rb index 0d188d68..2019cf37 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/admin/dashboard.html.erb b/app/views/admin/dashboard.html.erb index 00d8f498..e393baee 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,23 @@
- 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.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 || 0) } + + { + name: year, + data: Date::ABBR_MONTHNAMES.reject(&:nil?).map { |month| [month, totals_per_month[month]] } + } + }, + colors: [content_type.hex_color] + %>
@@ -86,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] + %> @@ -98,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] + %> @@ -108,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] + %> @@ -120,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] + %> @@ -131,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] + %> @@ -143,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'] + %> @@ -154,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'] + %> @@ -166,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'] + %> @@ -177,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'] + %> @@ -189,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] + %> @@ -199,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] + %> @@ -210,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] + %> @@ -221,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] + %> diff --git a/app/views/main/components/_active_discussions.html.erb b/app/views/main/components/_active_discussions.html.erb new file mode 100644 index 00000000..d591ffd4 --- /dev/null +++ b/app/views/main/components/_active_discussions.html.erb @@ -0,0 +1,18 @@ + diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index b93f5423..0eee24a5 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -62,19 +62,25 @@ <%= render partial: 'main/components/serendipitous_question', locals: { } %>

- Add another page + Create a new page

<%= render partial: 'main/components/create_new_page_list', locals: { } %>
-

- Your recent edits + +

+ <%= link_to 'Active discussions', thredded_path %> +

+ <%= render partial: 'main/components/active_discussions', locals: { discussions: @most_recent_threads } %> + +

+ <%= link_to 'Your recent edits', recent_content_path %>

<%= render partial: 'main/components/recently_edited_pages', locals: { } %>
- + 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