Merge branch 'master' into tailwind-redesign

This commit is contained in:
drusepth 2022-11-22 14:29:02 -08:00
commit 62edc3f4b1
9 changed files with 295 additions and 41 deletions

View File

@ -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

View File

@ -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!")

View File

@ -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

View File

@ -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

View File

@ -5,10 +5,10 @@
<div class="card-title">
90-day signups
<span class="right grey-text">
<%= number_with_delimiter User.last.id %> total
<%= number_with_delimiter User.last.id %> total users
</span>
</div>
<%= area_chart @reports.pluck(:day, :user_signups), colors: ['#2196F3'] %>
<%= area_chart @reports.limit(90).pluck(:day, :user_signups), colors: ['#2196F3'] %>
</div>
</div>
</div>
@ -16,18 +16,23 @@
<div class="card">
<div class="card-content">
<div class="card-title">
Monthly subscriptions
90-day monthly subscriptions
<span class="right grey-text">
<%= 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
</span>
</div>
<%=
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']
%>
<div>
90-day net:
<%= sprintf "%+d", @reports.limit(90).sum(:new_monthly_subscriptions) - @reports.limit(90).sum(:ended_monthly_subscriptions) %>
subscriptions
</div>
</div>
</div>
</div>
@ -35,16 +40,23 @@
<div class="card">
<div class="card-content">
<div class="card-title">
Trimonthly subscriptons
90-day trimonthly subscriptons
<span class="right grey-text">
<%= 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
</span>
</div>
<%= 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']
%>
<div>
90-day net:
<%= sprintf "%+d", @reports.limit(90).sum(:new_trimonthly_subscriptions) - @reports.limit(90).sum(:ended_trimonthly_subscriptions) %>
subscriptions
</div>
</div>
</div>
</div>
@ -52,16 +64,23 @@
<div class="card">
<div class="card-content">
<div class="card-title">
Annual subscriptions
90-day annual subscriptions
<span class="right grey-text">
<%= 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
</span>
</div>
<%= 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']
%>
<div>
90-day net:
<%= sprintf "%+d", @reports.limit(90).sum(:new_annual_subscriptions) - @reports.limit(90).sum(:ended_annual_subscriptions) %>
subscriptions
</div>
</div>
</div>
</div>
@ -71,10 +90,23 @@
<div class="card">
<div class="card-content">
<div class="card-title">
New <%= content_type.name.pluralize %>
New <%= content_type.name.pluralize %> each day
<span class="right grey-text"><%= number_with_delimiter content_type.last.id %> total</span>
</div>
<%= 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]
%>
</div>
</div>
</div>
@ -86,7 +118,20 @@
New timelines
<span class="right grey-text"><%= number_with_delimiter Timeline.last.id %> total</span>
</div>
<%= 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]
%>
</div>
</div>
</div>
@ -98,7 +143,20 @@
New stream shares
<span class="right grey-text"><%= number_with_delimiter ContentPageShare.last.id %> total</span>
</div>
<%= 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]
%>
</div>
</div>
</div>
@ -108,7 +166,20 @@
<div class="card-title">
New stream comments
</div>
<%= 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]
%>
</div>
</div>
</div>
@ -120,7 +191,20 @@
New collections
<span class="right grey-text"><%= number_with_delimiter PageCollection.last.id %> total</span>
</div>
<%= 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]
%>
</div>
</div>
</div>
@ -131,7 +215,20 @@
New collection submissions
<span class="right grey-text"><%= number_with_delimiter PageCollectionSubmission.last.id %> total</span>
</div>
<%= 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]
%>
</div>
</div>
</div>
@ -143,7 +240,20 @@
New discussion threads
<span class="right grey-text"><%= number_with_delimiter Thredded::Topic.last.id %> total</span>
</div>
<%= 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']
%>
</div>
</div>
</div>
@ -154,7 +264,20 @@
New discussion replies
<span class="right grey-text"><%= number_with_delimiter Thredded::Post.last.id %> total</span>
</div>
<%= 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']
%>
</div>
</div>
</div>
@ -166,7 +289,20 @@
New private discussions
<span class="right grey-text"><%= number_with_delimiter Thredded::PrivateTopic.last.id %> total</span>
</div>
<%= 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']
%>
</div>
</div>
</div>
@ -177,7 +313,20 @@
New private replies
<span class="right grey-text"><%= number_with_delimiter Thredded::PrivatePost.last.id %> total</span>
</div>
<%= 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']
%>
</div>
</div>
</div>
@ -189,7 +338,20 @@
New documents
<span class="right grey-text"><%= number_with_delimiter Document.last.id %> total</span>
</div>
<%= 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]
%>
</div>
</div>
</div>
@ -199,7 +361,20 @@
<div class="card-title">
Updated documents
</div>
<%= 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]
%>
</div>
</div>
</div>
@ -210,7 +385,20 @@
Document revisions
<span class="right grey-text"><%= number_with_delimiter DocumentRevision.last.id %> total</span>
</div>
<%= 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]
%>
</div>
</div>
</div>
@ -221,7 +409,20 @@
New document analyses
<span class="right grey-text"><%= number_with_delimiter DocumentAnalysis.last.id %> total</span>
</div>
<%= 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]
%>
</div>
</div>
</div>

View File

@ -0,0 +1,18 @@
<ul role="list" class="space-y-2 flex mb-8">
<% discussions.each do |topic| %>
<%= link_to topic, class: 'w-full' do %>
<li class="text-sm text-black hover:text-blue-800">
<i class="material-icons float-left mr-2 text-blue-500">forum</i>
<div><%= truncate(topic.title, length: 70) %></div>
<div>
<small>
<%= pluralize (topic.posts.count - 1), 'reply' %>
</small>
<small>
in <strong><%= topic.messageboard.name %></strong>
</small>
</div>
</li>
<% end %>
<% end %>
</ul>

View File

@ -62,19 +62,25 @@
<%= render partial: 'main/components/serendipitous_question', locals: { } %>
<h2 class="text-sm leading-6 font-medium text-gray-500 mb-2 text-center mt-4">
Add another page
Create a new page
</h2>
<%= render partial: 'main/components/create_new_page_list', locals: { } %>
</div>
<div class="col-span-3">
<h2 class="text-sm leading-6 font-medium text-gray-500 mb-2 text-center">
Your recent edits
<h2 class="text-sm leading-6 font-medium text-gray-500 hover:text-gray-800 mb-2 text-center">
<%= link_to 'Active discussions', thredded_path %>
</h2>
<%= render partial: 'main/components/active_discussions', locals: { discussions: @most_recent_threads } %>
<h2 class="text-sm leading-6 font-medium text-gray-500 hover:text-gray-800 mb-2 text-center">
<%= link_to 'Your recent edits', recent_content_path %>
</h2>
<%= render partial: 'main/components/recently_edited_pages', locals: { } %>
</div>
</div>
</main>
</div>
</div>

View File

@ -0,0 +1,18 @@
<% if Date.current <= 'November 9, 2022'.to_date && show_notice?(id: 6) %>
<div class="col s12 m5 l4">
<div class="grey-text uppercase center">
Free for everyone
</div>
<%= link_to main_app.customization_content_types_path do %>
<div class="card-panel hoverable">
<div class="valign-wrapper black-text">
<i class="material-icons grey-bordered-text <%= Government.text_color %>" class="left" style="font-size: 3em; margin-right: 0.3em;"><%= Government.icon %></i>
<div>
Government pages are free to create for all users until November 17.<br />
<small>Just turn them on and start creating!</small>
</div>
</div>
</div>
<% end %>
</div>
<% end %>

View File

@ -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