From 79415904b897c09b00ef49a57aae93053712c443 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 19 Jul 2021 14:42:04 -0700 Subject: [PATCH 001/149] add start to green estimation service --- app/services/green_service.rb | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 app/services/green_service.rb diff --git a/app/services/green_service.rb b/app/services/green_service.rb new file mode 100644 index 00000000..e6e39fea --- /dev/null +++ b/app/services/green_service.rb @@ -0,0 +1,53 @@ +class GreenService < Service + AVERAGE_WORDS_PER_PAGE = 500 + AVERAGE_TIMELINE_EVENTS_PER_PAGE = 3 + + def physical_pages_equivalent_for(worldbuilding_page_type) + # TODO: This would be better estimated with [average] word counts from pages (or a real total), + # but we don't have that data computed (and definitely don't want to do so on each page load). + # Until we have a better solution, these page counts come from printing out notebook pages + # from http://www.notebook-paper.com/ + + case worldbuilding_page_type + when "Universe" then 2 * Universe.last.id + when "Character" then 8 * Character.last.id + when "Location" then 4 * Location.last.id + when "Item" then 2 * Item.last.id + when "Building" then 8 * Building.last.id + when "Condition" then 4 * Condition.last.id + when "Continent" then 6 * Continent.last.id + when "Country" then 5 * Country.last.id + when "Creature" then 8 * Creature.last.id + when "Deity" then 5 * Deity.last.id + when "Flora" then 4 * Flora.last.id + when "Food" then 5 * Food.last.id + when "Government" then 6 * Government.last.id + when "Group" then 4 * Group.last.id + when "Job" then 4 * Job.last.id + when "Landmark" then 3 * Landmark.last.id + when "Language" then 5 * Language.last.id + when "Lore" then 10 * Lore.last.id + when "Magic" then 4 * Magic.last.id + when "Planet" then 6 * Planet.last.id + when "Race" then 4 * Race.last.id + when "Religion" then 3 * Religion.last.id + when "Scene" then 2 * Scene.last.id + when "School" then 6 * School.last.id + when "Sport" then 4 * Sport.last.id + when "Technology" then 4 * Technology.last.id + when "Town" then 4 * Town.last.id + when "Tradition" then 3 * Tradition.last.id + when "Vehicle" then 4 * Vehicle.last.id + else + raise "Unknown green estimate: #{worldbuilding_page_type}" + end + end + + def total_document_pages_equivalent + (Document.with_deleted.sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).to_i + end + + def total_timeline_pages_equivalent + (TimelineEvent.last.id / AVERAGE_TIMELINE_EVENTS_PER_PAGE.to_f).to_i + end +end \ No newline at end of file From 01d6ba2c5c5761143dd2fa4c2f3da128865ebd1f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 19 Jul 2021 22:02:07 -0700 Subject: [PATCH 002/149] add community footprint --- app/controllers/data_controller.rb | 3 + app/services/green_service.rb | 67 +++++------ app/views/data/green.html.erb | 176 +++++++++++++++++++++++++++++ app/views/data/index.html.erb | 16 ++- config/routes.rb | 1 + 5 files changed, 229 insertions(+), 34 deletions(-) create mode 100644 app/views/data/green.html.erb diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb index ac5737f4..f42eef7e 100644 --- a/app/controllers/data_controller.rb +++ b/app/controllers/data_controller.rb @@ -140,6 +140,9 @@ class DataController < ApplicationController @share_link = "https://www.notebook.ai/?referral=#{current_user.referral_code.code}" end + def green + end + private def set_sidenav_expansion diff --git a/app/services/green_service.rb b/app/services/green_service.rb index e6e39fea..73440ba9 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -1,53 +1,54 @@ class GreenService < Service AVERAGE_WORDS_PER_PAGE = 500 AVERAGE_TIMELINE_EVENTS_PER_PAGE = 3 + SHEETS_OF_PAPER_PER_TREE = 15_000 - def physical_pages_equivalent_for(worldbuilding_page_type) + def self.physical_pages_equivalent_for(worldbuilding_page_type) # TODO: This would be better estimated with [average] word counts from pages (or a real total), # but we don't have that data computed (and definitely don't want to do so on each page load). # Until we have a better solution, these page counts come from printing out notebook pages - # from http://www.notebook-paper.com/ + # from http://www.notebook-paper.com/ case worldbuilding_page_type - when "Universe" then 2 * Universe.last.id - when "Character" then 8 * Character.last.id - when "Location" then 4 * Location.last.id - when "Item" then 2 * Item.last.id - when "Building" then 8 * Building.last.id - when "Condition" then 4 * Condition.last.id - when "Continent" then 6 * Continent.last.id - when "Country" then 5 * Country.last.id - when "Creature" then 8 * Creature.last.id - when "Deity" then 5 * Deity.last.id - when "Flora" then 4 * Flora.last.id - when "Food" then 5 * Food.last.id - when "Government" then 6 * Government.last.id - when "Group" then 4 * Group.last.id - when "Job" then 4 * Job.last.id - when "Landmark" then 3 * Landmark.last.id - when "Language" then 5 * Language.last.id - when "Lore" then 10 * Lore.last.id - when "Magic" then 4 * Magic.last.id - when "Planet" then 6 * Planet.last.id - when "Race" then 4 * Race.last.id - when "Religion" then 3 * Religion.last.id - when "Scene" then 2 * Scene.last.id - when "School" then 6 * School.last.id - when "Sport" then 4 * Sport.last.id - when "Technology" then 4 * Technology.last.id - when "Town" then 4 * Town.last.id - when "Tradition" then 3 * Tradition.last.id - when "Vehicle" then 4 * Vehicle.last.id + when "Universe" then 2 + when "Character" then 8 + when "Location" then 4 + when "Item" then 2 + when "Building" then 8 + when "Condition" then 4 + when "Continent" then 6 + when "Country" then 5 + when "Creature" then 8 + when "Deity" then 5 + when "Flora" then 4 + when "Food" then 5 + when "Government" then 6 + when "Group" then 4 + when "Job" then 4 + when "Landmark" then 3 + when "Language" then 5 + when "Lore" then 10 + when "Magic" then 4 + when "Planet" then 6 + when "Race" then 4 + when "Religion" then 3 + when "Scene" then 2 + when "School" then 6 + when "Sport" then 4 + when "Technology" then 4 + when "Town" then 4 + when "Tradition" then 3 + when "Vehicle" then 4 else raise "Unknown green estimate: #{worldbuilding_page_type}" end end - def total_document_pages_equivalent + def self.total_document_pages_equivalent (Document.with_deleted.sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).to_i end - def total_timeline_pages_equivalent + def self.total_timeline_pages_equivalent (TimelineEvent.last.id / AVERAGE_TIMELINE_EVENTS_PER_PAGE.to_f).to_i end end \ No newline at end of file diff --git a/app/views/data/green.html.erb b/app/views/data/green.html.erb new file mode 100644 index 00000000..4169a552 --- /dev/null +++ b/app/views/data/green.html.erb @@ -0,0 +1,176 @@ +

+ <%= link_to data_vault_path, class: 'grey-text tooltipped', style: 'position: relative; top: 4px;', data: { + position: 'bottom', + enterDelay: '500', + tooltip: "Back to your Data Vault" + } do %> + arrow_back + <% end %> + Your paper footprint +

+ +<% + total_pages_equivalent = 0 +%> + +
+
+
+ All the added functionality of Notebook.ai isn't the only benefit of going digital. Backing your ideas up in the cloud + instead of on paper also saves trees! +
+
+ +
+
+
+
Your personal paper footprint
+ + + + + + + + + + + <% @current_user_content.each do |content_type, content_list| %> + <% + content_list_count = content_list.count + + physical_page_equivalent = case content_type + when 'Timeline' + GreenService::AVERAGE_TIMELINE_EVENTS_PER_PAGE * TimelineEvent.where(timeline_id: content_list.map(&:id)).count + when 'Document' + [ + content_list.inject(0) { |sum, doc| sum + (doc.cached_word_count || 0) } / GreenService::AVERAGE_WORDS_PER_PAGE.to_f, + content_list_count + ].max + else + GreenService.physical_pages_equivalent_for(content_type) * content_list_count + end + + tree_equivalent = physical_page_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE + + total_pages_equivalent += physical_page_equivalent + %> + + + + + + <% end %> + + + + + + +
Digital contentEquivalent physical pagesEquivalent trees
+ + <%= content_class_from_name(content_type).icon %> + + <%= pluralize content_list_count, content_type.pluralize %> + + copy_all + <%= pluralize physical_page_equivalent, 'page' %> + + park + <%= pluralize tree_equivalent.round(5), 'tree' %> +
Totals + + copy_all + <%= pluralize total_pages_equivalent, 'page' %> + + + + park + <%= pluralize total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE.round(5), 'tree' %> + saved + +
+
+
+
+
+ + + + +<% + total_pages_equivalent = 0 +%> + +
+
+
+
+
Our community paper footprint
+

Across all Notebook.ai pages...

+ + + + + + + + + + + <% Rails.application.config.content_type_names[:all].each do |content_type| %> + <% + content_list_count = content_class_from_name(content_type).last.try(:id) || 0 + + physical_page_equivalent = case content_type + when 'Timeline' + GreenService.total_timeline_pages_equivalent + when 'Document' + GreenService.total_document_pages_equivalent + else + GreenService.physical_pages_equivalent_for(content_type) * content_list_count + end + + tree_equivalent = physical_page_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE + + total_pages_equivalent += physical_page_equivalent + %> + + + + + + <% end %> + + + + + + +
Digital contentEquivalent physical pagesEquivalent trees
+ + <%= content_class_from_name(content_type).icon %> + + <%= pluralize content_list_count, content_type.pluralize %> + + copy_all + <%= pluralize physical_page_equivalent, 'page' %> + + park + <%= pluralize tree_equivalent.round(5), 'tree' %> +
Totals + + copy_all + <%= pluralize total_pages_equivalent, 'page' %> + + + + park + <%= pluralize total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE.round(5), 'tree' %> + saved + +
+
+
+
+
diff --git a/app/views/data/index.html.erb b/app/views/data/index.html.erb index b1a3e4a6..1b891f83 100644 --- a/app/views/data/index.html.erb +++ b/app/views/data/index.html.erb @@ -111,6 +111,20 @@ <% end %> +
+ <%= link_to green_path, class: 'black-text' do %> +
+
+ public +
Eco footprint
+

+ How many trees have you saved by switching to digital? +

+
+
+ <% end %> +
+
<%= link_to discussions_path, class: 'black-text' do %>
@@ -182,7 +196,7 @@
<%# this could actually be a cool s12 banner if we flesh out the help center with guides and stuff %> -
+
<%= link_to help_center_path, class: 'black-text' do %>
diff --git a/config/routes.rb b/config/routes.rb index 6e45512b..ee88c9ab 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -139,6 +139,7 @@ Rails.application.routes.draw do get '/uploads', to: 'data#uploads' get '/discussions', to: 'data#discussions' get '/collaboration', to: 'data#collaboration' + get '/green', to: 'data#green' scope 'yearly' do get '/', to: 'data#yearly_index', as: :year_in_review get '/:year', to: 'data#review_year', as: :review_year From faf34ddc9e4103ceed7044a5b66c8da7aff9273a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 19 Jul 2021 23:01:23 -0700 Subject: [PATCH 003/149] commas --- app/services/green_service.rb | 2 +- app/views/data/green.html.erb | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/services/green_service.rb b/app/services/green_service.rb index 73440ba9..d42b52fe 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -45,7 +45,7 @@ class GreenService < Service end def self.total_document_pages_equivalent - (Document.with_deleted.sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).to_i + (Document.with_deleted.sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).round end def self.total_timeline_pages_equivalent diff --git a/app/views/data/green.html.erb b/app/views/data/green.html.erb index 4169a552..0f9d6da3 100644 --- a/app/views/data/green.html.erb +++ b/app/views/data/green.html.erb @@ -64,7 +64,8 @@ copy_all - <%= pluralize physical_page_equivalent, 'page' %> + <%= number_with_delimiter physical_page_equivalent %> + <%= 'page'.pluralize physical_page_equivalent %> park @@ -77,13 +78,16 @@ copy_all - <%= pluralize total_pages_equivalent, 'page' %> + <%= number_with_delimiter total_pages_equivalent %> + <%= 'page'.pluralize total_pages_equivalent %> park - <%= pluralize total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE.round(5), 'tree' %> + <% trees_saved = total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE %> + <%= number_with_delimiter trees_saved.round(5) %> + <%= 'tree'.pluralize trees_saved %> saved @@ -140,15 +144,18 @@ <%= content_class_from_name(content_type).icon %> - <%= pluralize content_list_count, content_type.pluralize %> + <%= number_with_delimiter content_list_count %> + <%= content_type.pluralize content_list_count %> copy_all - <%= pluralize physical_page_equivalent, 'page' %> + <%= number_with_delimiter physical_page_equivalent %> + <%= 'page'.pluralize physical_page_equivalent %> park - <%= pluralize tree_equivalent.round(5), 'tree' %> + <%= number_with_delimiter tree_equivalent.round(5) %> + <%= 'tree'.pluralize tree_equivalent %> <% end %> @@ -157,7 +164,8 @@ copy_all - <%= pluralize total_pages_equivalent, 'page' %> + <%= number_with_delimiter total_pages_equivalent %> + <%= 'page'.pluralize total_pages_equivalent %> From f87dd8e0e9fb23b6b7d2b347f56636636005f8f3 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 19 Jul 2021 23:49:31 -0700 Subject: [PATCH 004/149] Tweaks --- app/views/data/green.html.erb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/data/green.html.erb b/app/views/data/green.html.erb index 0f9d6da3..bda0eced 100644 --- a/app/views/data/green.html.erb +++ b/app/views/data/green.html.erb @@ -78,7 +78,7 @@ copy_all - <%= number_with_delimiter total_pages_equivalent %> + <%= number_with_delimiter total_pages_equivalent.round %> <%= 'page'.pluralize total_pages_equivalent %> @@ -171,8 +171,9 @@ park - <%= pluralize total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE.round(5), 'tree' %> - saved + <% trees_saved = total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE %> + <%= number_with_delimiter trees_saved.round(5) %> + <%= 'tree'.pluralize trees_saved %> From 349a6e7ca3fe1a367a0626dee314222d9665f009 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 02:37:13 -0700 Subject: [PATCH 005/149] reduce some estimates --- app/services/green_service.rb | 4 ++-- app/views/data/green.html.erb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/services/green_service.rb b/app/services/green_service.rb index d42b52fe..9460b835 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -11,7 +11,7 @@ class GreenService < Service case worldbuilding_page_type when "Universe" then 2 - when "Character" then 8 + when "Character" then 6 when "Location" then 4 when "Item" then 2 when "Building" then 8 @@ -27,7 +27,7 @@ class GreenService < Service when "Job" then 4 when "Landmark" then 3 when "Language" then 5 - when "Lore" then 10 + when "Lore" then 8 when "Magic" then 4 when "Planet" then 6 when "Race" then 4 diff --git a/app/views/data/green.html.erb b/app/views/data/green.html.erb index bda0eced..7fb0e7c7 100644 --- a/app/views/data/green.html.erb +++ b/app/views/data/green.html.erb @@ -16,7 +16,7 @@
- All the added functionality of Notebook.ai isn't the only benefit of going digital. Backing your ideas up in the cloud + All of the added functionality of Notebook.ai over a traditional paper notebook isn't the only benefit of going digital. Backing your ideas up in the cloud instead of on paper also saves trees!
@@ -174,6 +174,7 @@ <% trees_saved = total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE %> <%= number_with_delimiter trees_saved.round(5) %> <%= 'tree'.pluralize trees_saved %> + saved From f6cb4429913e719e753eb06b18f5dc23cd7e51a6 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 13:31:05 -0700 Subject: [PATCH 006/149] update sheets per tree count --- app/services/green_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/green_service.rb b/app/services/green_service.rb index 9460b835..a426885e 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -1,7 +1,7 @@ class GreenService < Service AVERAGE_WORDS_PER_PAGE = 500 AVERAGE_TIMELINE_EVENTS_PER_PAGE = 3 - SHEETS_OF_PAPER_PER_TREE = 15_000 + SHEETS_OF_PAPER_PER_TREE = 10_000 # source: https://ribble-pack.co.uk/blog/much-paper-comes-one-tree def self.physical_pages_equivalent_for(worldbuilding_page_type) # TODO: This would be better estimated with [average] word counts from pages (or a real total), From f2ec93a4d745be4d03e937b36ac5be082e5e5ff9 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 14:12:41 -0700 Subject: [PATCH 007/149] be a little more conservative in tree estimate tho --- app/services/green_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/green_service.rb b/app/services/green_service.rb index a426885e..d68b3301 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -1,7 +1,7 @@ class GreenService < Service AVERAGE_WORDS_PER_PAGE = 500 AVERAGE_TIMELINE_EVENTS_PER_PAGE = 3 - SHEETS_OF_PAPER_PER_TREE = 10_000 # source: https://ribble-pack.co.uk/blog/much-paper-comes-one-tree + SHEETS_OF_PAPER_PER_TREE = 11_000 # source: https://ribble-pack.co.uk/blog/much-paper-comes-one-tree def self.physical_pages_equivalent_for(worldbuilding_page_type) # TODO: This would be better estimated with [average] word counts from pages (or a real total), From dd5f0f20f0ba44f2fbbd83e145cbef82492a749f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 17:20:49 -0700 Subject: [PATCH 008/149] add public site-wide green report --- app/controllers/main_controller.rb | 25 ++++++ app/services/green_service.rb | 13 ++- app/views/data/green.html.erb | 2 +- app/views/main/paper.html.erb | 126 +++++++++++++++++++++++++++++ config/routes.rb | 1 + 5 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 app/views/main/paper.html.erb diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index bbee013a..00de0c7c 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -35,6 +35,31 @@ class MainController < ApplicationController def sascon end + def paper + @navbar_color = '#4CAF50' + + @total_notebook_pages = 0 + @total_pages_equivalent = 0 + @total_trees_saved = 0 + + @per_page_savings = {} + + (Rails.application.config.content_types[:all] + [Timeline, Document]).each do |content_type| + physical_page_equivalent = GreenService.total_physical_pages_equivalent(content_type) + tree_equivalent = physical_page_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE + + @per_page_savings[content_type.name] = { + digital: content_type.last.try(:id) || 0, + pages: physical_page_equivalent, + trees: tree_equivalent + } + + @total_notebook_pages += @per_page_savings.dig(content_type.name, :digital) + @total_pages_equivalent += @per_page_savings.dig(content_type.name, :pages) + @total_trees_saved += @per_page_savings.dig(content_type.name, :trees) + end + end + def prompts @sidenav_expansion = 'writing' @navbar_color = '#FF9800' diff --git a/app/services/green_service.rb b/app/services/green_service.rb index d68b3301..d1be14d9 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -45,10 +45,21 @@ class GreenService < Service end def self.total_document_pages_equivalent - (Document.with_deleted.sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).round + (Document.with_deleted.where.not(body: ["", nil]).sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).round end def self.total_timeline_pages_equivalent (TimelineEvent.last.id / AVERAGE_TIMELINE_EVENTS_PER_PAGE.to_f).to_i end + + def self.total_physical_pages_equivalent(content_type) + case content_type.name + when 'Timeline' + GreenService.total_timeline_pages_equivalent + when 'Document' + GreenService.total_document_pages_equivalent + else + GreenService.physical_pages_equivalent_for(content_type.name) * (content_type.last.try(:id) || 0) + end + end end \ No newline at end of file diff --git a/app/views/data/green.html.erb b/app/views/data/green.html.erb index 7fb0e7c7..3e369cbb 100644 --- a/app/views/data/green.html.erb +++ b/app/views/data/green.html.erb @@ -122,7 +122,7 @@ - <% Rails.application.config.content_type_names[:all].each do |content_type| %> + <% (Rails.application.config.content_type_names[:all] + ["Timeline", "Document"]).each do |content_type| %> <% content_list_count = content_class_from_name(content_type).last.try(:id) || 0 diff --git a/app/views/main/paper.html.erb b/app/views/main/paper.html.erb new file mode 100644 index 00000000..ce9f8623 --- /dev/null +++ b/app/views/main/paper.html.erb @@ -0,0 +1,126 @@ +
+
+
+
+ <%= + image_tag 'tristan/small.png', class: 'right hide-on-small-only', style: 'margin-left: 2em' + %> + +
Going digital saves paper and trees!
+
+

+ It's well-known that Notebook.ai offers a wide variety of features that just aren't + possible with traditional paper notebooks. However, those aren't the only benefits of + going digital! +

+
+

+ Whether you're worldbuilding with our specialized notebook pages, outlining story + timelines, or writing your next novel, every page you create in Notebook.ai directly + contributes to less paper being used — and fewer trees cut down! +

+
+
+
+
+ +
+
+

<%= number_with_delimiter @total_notebook_pages %>

+ digital ideas stored +
+
+
+
+

<%= number_with_delimiter @total_pages_equivalent %>

+ equivalent physical pages +
+
+
+
+ park +

<%= number_with_delimiter @total_trees_saved.round %>

+ trees saved +
+
+ +
+
+

+ park + Note: The average 40-foot pine tree typically yields between 10,000 and 20,000 notebook-quality sheets of paper. + For the estimations on this page, we're using a conservative estimate of + <%= number_with_delimiter GreenService::SHEETS_OF_PAPER_PER_TREE %> pages per tree. +

+
+
+
+ +
+
+
+
+
Our community paper footprint
+ + + + + + + + + + + + <% (Rails.application.config.content_type_names[:all] + ["Timeline", "Document"]).each do |content_type| %> + <% + content_list_count = @per_page_savings.dig(content_type, :digital) + physical_page_equivalent = @per_page_savings.dig(content_type, :pages) + tree_equivalent = @per_page_savings.dig(content_type, :trees) + %> + + + + + + <% end %> + + + + + + +
Digital contentEquivalent physical pagesEquivalent trees
+ + <%= content_class_from_name(content_type).icon %> + + <%= number_with_delimiter content_list_count %> + <%= content_type.pluralize content_list_count %> + + copy_all + <%= number_with_delimiter physical_page_equivalent %> + <%= 'page'.pluralize physical_page_equivalent %> + + park + <%= number_with_delimiter tree_equivalent.round(5) %> + <%= 'tree'.pluralize tree_equivalent %> +
Totals + + copy_all + <%= number_with_delimiter @total_pages_equivalent %> + <%= 'page'.pluralize @total_pages_equivalent %> + + + + park + <%= number_with_delimiter @total_trees_saved.round(5) %> + <%= 'tree'.pluralize @total_trees_saved %> + saved + +
+
+
+
+
+ +notebook paper link \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index ee88c9ab..81bb58fd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -168,6 +168,7 @@ Rails.application.routes.draw do # Info pages scope '/about' do + get '/paper', to: 'main#paper', as: :green_paper get '/privacy', to: 'main#privacyinfo', as: :privacy_policy end From 1744b49ac3659b0d828a7af7961ebcaace06d0f1 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 17:30:19 -0700 Subject: [PATCH 009/149] add detail tooltips to green table --- app/views/main/paper.html.erb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/views/main/paper.html.erb b/app/views/main/paper.html.erb index ce9f8623..83c3a5f5 100644 --- a/app/views/main/paper.html.erb +++ b/app/views/main/paper.html.erb @@ -88,8 +88,17 @@ copy_all - <%= number_with_delimiter physical_page_equivalent %> - <%= 'page'.pluralize physical_page_equivalent %> + <% if content_type == 'Timeline' %> + <% tooltip = "This estimate is based on the average timeline having approximately #{GreenService::AVERAGE_TIMELINE_EVENTS_PER_PAGE} detailed events per page when printed." %> + <% elsif content_type == 'Document' %> + <% tooltip = "This estimate is based on the total word count across all documents on Notebook.ai." %> + <% else %> + <% tooltip = "This estimate is based on the average #{content_type} being approximately #{GreenService.physical_pages_equivalent_for(content_type)} physical pages long when printed." %> + <% end %> + + <%= number_with_delimiter physical_page_equivalent %> + <%= 'page'.pluralize physical_page_equivalent %> + park From 98480c55492202df82dcce08ca50a55a53f8eea5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 17:58:42 -0700 Subject: [PATCH 010/149] permission update for debugging abusive doc --- app/authorizers/document_authorizer.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/authorizers/document_authorizer.rb b/app/authorizers/document_authorizer.rb index c8f56644..d30f5c96 100644 --- a/app/authorizers/document_authorizer.rb +++ b/app/authorizers/document_authorizer.rb @@ -7,6 +7,7 @@ class DocumentAuthorizer < ApplicationAuthorizer def readable_by?(user) return true if user && resource.user_id == user.id + return true if user && user.site_administrator? return true if resource.privacy == 'public' return true if resource.universe.present? && resource.universe.privacy == 'public' return true if user && resource.universe.present? && resource.universe.contributors.pluck(:user_id).include?(user.id) From 1ce86ab03e981f92e483c60326bd1dca5447ac66 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 17:58:59 -0700 Subject: [PATCH 011/149] better estimate on document pages --- app/services/green_service.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/services/green_service.rb b/app/services/green_service.rb index d1be14d9..73490dfa 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -45,7 +45,17 @@ class GreenService < Service end def self.total_document_pages_equivalent - (Document.with_deleted.where.not(body: ["", nil]).sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).round + total_pages = 0 + + # Treat all <1-page documents as 1 page per document, since they'd print on separate pages + total_pages += Document.with_deleted.where('cached_word_count <= ?', AVERAGE_WORDS_PER_PAGE).count + + # For all >1-page documents, do a quick estimate of word count sum + num docs to also cover EOD page breaks + docs = Document.with_deleted.where.not(cached_word_count: nil).where('cached_word_count > ?', AVERAGE_WORDS_PER_PAGE) + total_pages += (docs.sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).round + total_pages += docs.count + + total_pages end def self.total_timeline_pages_equivalent From 29fae1e7457f3835463ae25b06405ee5c55fd8d8 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 17:59:06 -0700 Subject: [PATCH 012/149] table polish --- app/views/main/paper.html.erb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/main/paper.html.erb b/app/views/main/paper.html.erb index 83c3a5f5..06d5c685 100644 --- a/app/views/main/paper.html.erb +++ b/app/views/main/paper.html.erb @@ -93,7 +93,7 @@ <% elsif content_type == 'Document' %> <% tooltip = "This estimate is based on the total word count across all documents on Notebook.ai." %> <% else %> - <% tooltip = "This estimate is based on the average #{content_type} being approximately #{GreenService.physical_pages_equivalent_for(content_type)} physical pages long when printed." %> + <% tooltip = "This estimate is based on the average #{content_type} page being approximately #{GreenService.physical_pages_equivalent_for(content_type)} physical pages long when printed." %> <% end %> <%= number_with_delimiter physical_page_equivalent %> @@ -131,5 +131,3 @@
- -notebook paper link \ No newline at end of file From 28e5ffd469d649e2c44e5c64e146176ae45254ff Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 18:12:07 -0700 Subject: [PATCH 013/149] polish up green page --- app/views/main/paper.html.erb | 19 +++++++++++++------ config/routes.rb | 2 ++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/views/main/paper.html.erb b/app/views/main/paper.html.erb index 06d5c685..a27159e8 100644 --- a/app/views/main/paper.html.erb +++ b/app/views/main/paper.html.erb @@ -37,18 +37,18 @@
-
+
park -

<%= number_with_delimiter @total_trees_saved.round %>

+

<%= number_with_delimiter @total_trees_saved.round %>

trees saved
-
+

park - Note: The average 40-foot pine tree typically yields between 10,000 and 20,000 notebook-quality sheets of paper. + The average 40-foot pine tree typically yields between 10,000 and 20,000 notebook-quality sheets of paper. For the estimations on this page, we're using a conservative estimate of <%= number_with_delimiter GreenService::SHEETS_OF_PAPER_PER_TREE %> pages per tree.

@@ -83,8 +83,15 @@ <%= content_class_from_name(content_type).icon %> - <%= number_with_delimiter content_list_count %> - <%= content_type.pluralize content_list_count %> + <% if ["Timeline", "Document"].include?(content_type) %> + <%= number_with_delimiter content_list_count %> + <%= content_type.pluralize content_list_count %> + <% else %> + <%= link_to send("#{content_type.downcase}_worldbuilding_info_path"), class: 'black-text' do %> + <%= number_with_delimiter content_list_count %> + <%= content_type.pluralize content_list_count %> + <% end %> + <% end %> copy_all diff --git a/config/routes.rb b/config/routes.rb index 81bb58fd..96b6af37 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -283,6 +283,8 @@ Rails.application.routes.draw do scope '/worldbuilding' do Rails.application.config.content_types[:all].each do |content_type| get content_type.name.downcase.pluralize, to: "information##{content_type.name.downcase.pluralize}", as: "#{content_type.name.downcase}_worldbuilding_info" + # TODO: documents info page + # TODO: timelines info page end end From 5cc1fd0fc6ec8d10ab9af6270dad2808d9cd80b8 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 18:17:40 -0700 Subject: [PATCH 014/149] give a little breathing room to content info pages --- app/views/information/content_type.html.erb | 34 +++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/app/views/information/content_type.html.erb b/app/views/information/content_type.html.erb index adeb57aa..e42a54d7 100644 --- a/app/views/information/content_type.html.erb +++ b/app/views/information/content_type.html.erb @@ -42,10 +42,13 @@
-

- searchable - Search your <%= pluralized_class_name.downcase %> -

+
+ searchable +

+ Search your <%= pluralized_class_name.downcase %> +

+
+

If you've got a lot of <%= pluralized_class_name.downcase %>, you can quickly get around to the right one with Notebook.ai's full-text search. It searches your entire notebook for anything you wrote about @@ -65,11 +68,13 @@

-

- lock - Private by default -

- +
+ lock +

+ Private by default +

+
+

Your ideas are valuable. Every <%= singular_class_name.downcase %> you create in Notebook.ai is owned by you, completely private by default, and only accessible to you.

@@ -83,10 +88,13 @@
-

- star - <%= (premium_page) ? 'Premium page' : 'Free page' %> -

+
+ star +

+ <%= (premium_page) ? 'Premium page' : 'Free page' %> +

+
+
<% if premium_page %>

<%= singular_class_name %> notebook pages require an active Premium subscription to create, but users on free plans can From ebc1e3d4b15c939c1ca12806d16edb4b7855c939 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 18:20:18 -0700 Subject: [PATCH 015/149] add icon --- app/views/information/content_type.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/information/content_type.html.erb b/app/views/information/content_type.html.erb index e42a54d7..d32b45c1 100644 --- a/app/views/information/content_type.html.erb +++ b/app/views/information/content_type.html.erb @@ -128,6 +128,10 @@

+ + <%= @content_type.icon %> + + Get a head start with a rich <%= singular_class_name.downcase %> template From ba44ecb1aabbe6c7bb6dc070a531798df043a617 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 18:28:39 -0700 Subject: [PATCH 016/149] more spacing on info pages --- app/views/information/content_type.html.erb | 148 ++++++++++---------- 1 file changed, 75 insertions(+), 73 deletions(-) diff --git a/app/views/information/content_type.html.erb b/app/views/information/content_type.html.erb index d32b45c1..66d05e72 100644 --- a/app/views/information/content_type.html.erb +++ b/app/views/information/content_type.html.erb @@ -124,7 +124,9 @@

-
+
 
+ +

@@ -136,84 +138,84 @@ <%= singular_class_name.downcase %> template

+
-
-
-
-

- Templates on Notebook.ai are what help our unique worldbuilding system better understand your world. -

-

- You can fill out as little or as much as you'd like on every new <%= singular_class_name.downcase %>. You'll see - progress indicators every time you edit it to show where you can make progress on, and our system will - intelligently generate questions for you around the site that will automatically save your answers - to the proper place on your <%= singular_class_name.downcase %> page. -

-

- Templates are also fully customizable across every <%= singular_class_name.downcase %> in your notebook. -

-

- You can browse the default template for <%= pluralized_class_name.downcase %> here; click any category - to see its questions. -

-
-
-
-
    - <% - YAML.load_file(Rails.root.join('config', 'attributes', "#{singular_class_name.downcase}.yml")).map do |category_name, category_details| - %> - <% next if category_name == :contributors %> -
  • -
    - <%= category_details[:icon] %> - <%= category_details[:label] %> -
    -
    - <% if category_name == :gallery %> -

    - This category lets you upload images to this <%= singular_class_name.downcase %>'s notebook page. -

    -
    -

    - It's great if you have sketches or artwork for your <%= singular_class_name.downcase %>, - but also works well for collecting visual inspiration, too! -

    - <% end %> - <% category_details.fetch(:attributes, []).each do |field| %> -

    - <%= field[:label] %> -

    -

    - <% if field[:field_type] == 'link' || field[:field_type] == 'universe' %> - This field allows you to link your other Notebook.ai pages to this <%= singular_class_name.downcase %>. - <% elsif field[:field_type] == 'tags' %> - This field lets you add clickable tags to your <%= pluralized_class_name.downcase %>. - <% else %> - <%= - I18n.translate "attributes.#{singular_class_name.downcase}.#{field[:label].downcase.gsub(/\s/, '_')}", - scope: :serendipitous_questions, - name: "this #{singular_class_name.downcase}", - default: 'Write as little or as much as you want!' - %> -
    - <%= field[:description].try(:html_safe) %> - <% end %> -

    -
    - <% end %> -
    -
  • - <% - end - %> -
-
+
+

+ Templates on Notebook.ai are what help our unique worldbuilding system better understand your world. +

+

+ You can fill out as little or as much as you'd like on every new <%= singular_class_name.downcase %>. You'll see + progress indicators every time you edit it to show where you can make progress on, and our system will + intelligently generate questions for you around the site that will automatically save your answers + to the proper place on your <%= singular_class_name.downcase %> page. +

+

+ Templates are also fully customizable across every <%= singular_class_name.downcase %> in your notebook. +

+

+ You can browse the default template for <%= pluralized_class_name.downcase %> here; click any category + to see its questions. +

+
+
    + <% + YAML.load_file(Rails.root.join('config', 'attributes', "#{singular_class_name.downcase}.yml")).map do |category_name, category_details| + %> + <% next if category_name == :contributors %> +
  • +
    + <%= category_details[:icon] %> + <%= category_details[:label] %> +
    +
    + <% if category_name == :gallery %> +

    + This category lets you upload images to this <%= singular_class_name.downcase %>'s notebook page. +

    +
    +

    + It's great if you have sketches or artwork for your <%= singular_class_name.downcase %>, + but also works well for collecting visual inspiration, too! +

    + <% end %> + <% category_details.fetch(:attributes, []).each do |field| %> +
    + <%= field[:label] %> +
    +
    + <% if field[:field_type] == 'link' || field[:field_type] == 'universe' %> + This field allows you to link your other Notebook.ai pages to this <%= singular_class_name.downcase %>. + <% elsif field[:field_type] == 'tags' %> + This field lets you add clickable tags to your <%= pluralized_class_name.downcase %>. + <% else %> + <%= + I18n.translate "attributes.#{singular_class_name.downcase}.#{field[:label].downcase.gsub(/\s/, '_')}", + scope: :serendipitous_questions, + name: "this #{singular_class_name.downcase}", + default: 'Write as little or as much as you want!' + %> +
    + <%= field[:description].try(:html_safe) %> + <% end %> +
    +
    + <% end %> +
    +
  • + <% + end + %> +
+
+ +
 
+
From ea77009843bec5124a0769dd009ade673f0c7ea0 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 19:02:43 -0700 Subject: [PATCH 017/149] html polish --- app/views/information/content_type.html.erb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/views/information/content_type.html.erb b/app/views/information/content_type.html.erb index 66d05e72..b8ad0b31 100644 --- a/app/views/information/content_type.html.erb +++ b/app/views/information/content_type.html.erb @@ -223,12 +223,13 @@ photo_library Upload images to your <%= singular_class_name.downcase %> +

<%= pluralized_class_name %> and other worldbuilding pages all come with a dedicated area to upload and showcase your own uploaded images.

All users start out with 50MB of image storage space available for their notebook (usually around 250-500 images), but - Premium users receive an extra 10GB (10,000MB) of storage space for plenty of wiggle room when decking your <%= singular_class_name.downcase %> + Premium users receive an extra 10GB (10,000MB) of storage space for plenty of wiggle room when decking your <%= pluralized_class_name.downcase %> out with all kinds of images.

@@ -246,6 +247,7 @@ vpn_lock Focus on <%= pluralized_class_name.downcase %> from a single universe +

Building entire fictional worlds is hard, and it gets even harder when you've got ideas spanning multiple universes or worlds.

@@ -268,6 +270,7 @@ group_add Invite others to collaborate +

Notebook.ai lets you add an unlimited number of collaborators to your universes. Each one has full access to work alongside you on your <%= pluralized_class_name.downcase %> and other pages within that universe. @@ -286,6 +289,7 @@ brightness_4 Work in light or dark mode +

Protect your eyes at night by choosing between light and dark themes at the click of a button, available across the entire website.

@@ -306,6 +310,7 @@ <%= @content_type.icon %> Build your <%= singular_class_name.downcase %> piece by piece with personalized writing prompts +

Once you've started creating a <%= singular_class_name.downcase %> or two, you'll start noticing our worldbuilding tool asking you personalized questions about those <%= pluralized_class_name.downcase %> around the site. @@ -356,22 +361,21 @@ <%= Document.icon %> Smoothly transition from worldbuilding to storytelling +

- Every account on Notebook.ai comes with unlimited document storage for you to bring your fictional worlds to life. + Every account on Notebook.ai comes with unlimited document storage and an integrated word processor for you to bring your fictional worlds to life. +

- There are a variety of writing tools for you to use, building on top of the foundation you lay from a world of <%= pluralized_class_name.downcase %> + Other integrated tools allow you to build upon the foundation you lay from a world of <%= pluralized_class_name.downcase %> and other notebook pages. Each one offers new ways to enrich your world and write better stories within them.

-

- Some ways you can use the writing tools in Notebook.ai with your worlds are listed here: -

-
+
  • <%= Timeline.icon %> @@ -405,6 +409,8 @@
+
 
+

<%= pluralized_class_name %> are just one of the <%= Rails.application.config.content_types[:all].count %> types of worldbuilding pages available From 25a3785db012c4f4f123add96d0db71090195bba Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 20 Jul 2021 19:09:38 -0700 Subject: [PATCH 018/149] add green link to content info page --- app/services/green_service.rb | 4 ++++ app/views/information/content_type.html.erb | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/services/green_service.rb b/app/services/green_service.rb index 73490dfa..6fdade0f 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -44,6 +44,10 @@ class GreenService < Service end end + def self.trees_saved_by(worldbuilding_page_type) + (physical_pages_equivalent_for(worldbuilding_page_type) * worldbuilding_page_type.constantize.last.id) / SHEETS_OF_PAPER_PER_TREE.to_f + end + def self.total_document_pages_equivalent total_pages = 0 diff --git a/app/views/information/content_type.html.erb b/app/views/information/content_type.html.erb index b8ad0b31..95366e10 100644 --- a/app/views/information/content_type.html.erb +++ b/app/views/information/content_type.html.erb @@ -216,6 +216,8 @@

 
+
<%= singular_class_name %> features
+
@@ -329,7 +331,14 @@
Our users have created
<%= number_with_delimiter @content_type.last.try(:id) || 0 %>
- <%= pluralized_class_name.downcase %> on Notebook.ai! + <%= pluralized_class_name.downcase %> on Notebook.ai +
+ <%= link_to green_paper_path, class: 'green-text' do %> + and saved + <%= number_with_delimiter GreenService.trees_saved_by(singular_class_name).round(2) %> + trees! + <% end %> +
From 3a53849baca7a31a84d3737947e3f5e99f1d7abb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Jul 2021 12:01:40 +0000 Subject: [PATCH 019/149] Bump redis from 4.3.1 to 4.4.0 Bumps [redis](https://github.com/redis/redis-rb) from 4.3.1 to 4.4.0. - [Release notes](https://github.com/redis/redis-rb/releases) - [Changelog](https://github.com/redis/redis-rb/blob/master/CHANGELOG.md) - [Commits](https://github.com/redis/redis-rb/compare/v4.3.1...v4.4.0) --- updated-dependencies: - dependency-name: redis dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..8614250e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1444,7 +1444,7 @@ GEM railties (>= 3.2) tilt redcarpet (3.5.1) - redis (4.3.1) + redis (4.4.0) remotipart (1.4.4) responders (3.0.1) actionpack (>= 5.0) From c385ffe084a4c04971c48205f66c891072387028 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Jul 2021 12:00:55 +0000 Subject: [PATCH 020/149] Bump puma from 5.3.2 to 5.4.0 Bumps [puma](https://github.com/puma/puma) from 5.3.2 to 5.4.0. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v5.3.2...v5.4.0) --- updated-dependencies: - dependency-name: puma dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 0a253993..4d680ba4 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ ruby "~> 2.7" # Server gem 'rails' -gem 'puma', '~> 5.3' +gem 'puma', '~> 5.4' gem 'puma-heroku' # gem 'bootsnap', require: false gem 'sprockets', '~> 3.7.2' diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..331ea9f5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1373,7 +1373,7 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) - puma (5.3.2) + puma (5.4.0) nio4r (~> 2.0) puma-heroku (2.0.0) puma (>= 5.0, < 6.0) @@ -1584,7 +1584,7 @@ DEPENDENCIES paypal_client pg (~> 1.2) pry - puma (~> 5.3) + puma (~> 5.4) puma-heroku rack-mini-profiler rails From 258be6f9179397a33abc33ec4e23300efa73deb3 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:00:11 -0700 Subject: [PATCH 021/149] -1 query --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 547bdd67..d233c16b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,7 +27,7 @@ class ApplicationController < ActionController::Base session.delete(:universe_id) elsif params[:universe].is_a?(String) && params[:universe].to_i.to_s == params[:universe] found_universe = Universe.find_by(id: params[:universe]) - found_universe = nil unless current_user.universes.include?(found_universe) || current_user.contributable_universes.include?(found_universe) + found_universe = nil unless found_universe.user_id == current_user.id || current_user.contributable_universes.include?(found_universe) session[:universe_id] = found_universe.id if found_universe end end From f3e61a2d57b00e9bf3ea8e016845d1c9780c3e3a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:02:43 -0700 Subject: [PATCH 022/149] -~3 queries --- app/controllers/application_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d233c16b..2079fea1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,8 +35,9 @@ class ApplicationController < ActionController::Base def set_universe_scope if user_signed_in? && session.key?(:universe_id) + # We generally trust that once a universe is set in the session, we don't need to keep re-verifying on every page load that the user + # still has access to that universe. @universe_scope = Universe.find_by(id: session[:universe_id]) - @universe_scope = nil unless current_user.universes.include?(@universe_scope) || current_user.contributable_universes.include?(@universe_scope) else @universe_scope = nil end From 8223f99f89915b5545e243b719d6c0447e1f3f7d Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:03:49 -0700 Subject: [PATCH 023/149] query smaller table --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2079fea1..aa4f19d3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,7 +27,7 @@ class ApplicationController < ActionController::Base session.delete(:universe_id) elsif params[:universe].is_a?(String) && params[:universe].to_i.to_s == params[:universe] found_universe = Universe.find_by(id: params[:universe]) - found_universe = nil unless found_universe.user_id == current_user.id || current_user.contributable_universes.include?(found_universe) + found_universe = nil unless found_universe.user_id == current_user.id || found_universe.contributors.pluck(:user_id).include?(current_user.id) session[:universe_id] = found_universe.id if found_universe end end From 1b50e1b21fea81972f96f327e55c6f98c8490d92 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:15:43 -0700 Subject: [PATCH 024/149] break cache methods out --- app/controllers/application_controller.rb | 57 +++++++++++++++++------ 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index aa4f19d3..fe36827b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base before_action :set_universe_scope before_action :cache_most_used_page_information - before_action :cache_forums_unread_counts before_action :set_metadata @@ -43,18 +42,36 @@ class ApplicationController < ActionController::Base end end - # Cache some super-common stuff we need for every page. For example, content lists for the side nav. + # Cache some super-common stuff we need for every page. For example, content lists for the side nav. This is a catch-all for most pages that render + # UI, but methods are also free to skip this filter and call the individual cache methods they need instead. def cache_most_used_page_information + cache_activated_content_types + cache_current_user_content + cache_notifications + cache_recently_edited_pages + cache_forums_unread_counts + end + + def cache_activated_content_types + @activated_content_types = [] + return unless user_signed_in? + + @activated_content_types = if user_signed_in? + ( + # Use config to dictate order, but AND to only include what a user has turned on + Rails.application.config.content_type_names[:all] & current_user.user_content_type_activators.pluck(:content_type) + ) + else + [] + end + end + + def cache_current_user_content @current_user_content = {} return unless user_signed_in? - @activated_content_types = ( - Rails.application.config.content_types[:all].map(&:name) & # Use config to dictate order, but AND to only include what a user has turned on - current_user.user_content_type_activators.pluck(:content_type) - ) - # We always want to cache Universes, even if they aren't explicitly turned on. - @current_user_content = current_user.content(content_types: @activated_content_types + ['Universe'], universe_id: @universe_scope.try(:id)) + @current_user_content = current_user.content(content_types: @activated_content_types + [Universe.name], universe_id: @universe_scope.try(:id)) # Likewise, we should also always cache Timelines & Documents if @universe_scope @@ -64,15 +81,25 @@ class ApplicationController < ActionController::Base @current_user_content['Timeline'] = current_user.timelines.to_a @current_user_content['Document'] = current_user.linkable_documents.includes([:user]).order('updated_at DESC').to_a end + end - # Fetch notifications - @user_notifications = current_user.notifications.order('happened_at DESC').limit(100) + def cache_notifications + @user_notifications = if user_signed_in? + current_user.notifications.order('happened_at DESC').limit(100) + else + [] + end + end - # Cache recently-edited pages - @recently_edited_pages = @current_user_content.values.flatten - .sort_by(&:updated_at) - .last(50) - .reverse + def recently_edited_pages + @recently_edited_pages = if user_signed_in? + @current_user_content.values.flatten + .sort_by(&:updated_at) + .last(50) + .reverse + else + [] + end end def cache_forums_unread_counts From 753452f314d26d1c4bf7721edd0267a782851244 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:19:55 -0700 Subject: [PATCH 025/149] contrib helper cache --- app/controllers/application_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fe36827b..7b99362f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -119,6 +119,14 @@ class ApplicationController < ActionController::Base end end + def cache_contributable_universe_ids + @contributable_universe_ids = if user_signed_in? + Contributor.where(user: current_user).pluck(:universe_id) + else + [] + end + end + def cache_linkable_content_for_each_content_type linkable_classes = Rails.application.config.content_types[:all].map(&:name) & current_user.user_content_type_activators.pluck(:content_type) linkable_classes += %w(Document Timeline) From 062fef26b8a8fcb3b5b955764bad4a3960da7cf0 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:21:02 -0700 Subject: [PATCH 026/149] don't requery if we repeat a cache call --- app/controllers/application_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7b99362f..055d7eeb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -56,7 +56,7 @@ class ApplicationController < ActionController::Base @activated_content_types = [] return unless user_signed_in? - @activated_content_types = if user_signed_in? + @activated_content_types ||= if user_signed_in? ( # Use config to dictate order, but AND to only include what a user has turned on Rails.application.config.content_type_names[:all] & current_user.user_content_type_activators.pluck(:content_type) @@ -69,6 +69,7 @@ class ApplicationController < ActionController::Base def cache_current_user_content @current_user_content = {} return unless user_signed_in? + return if @current_user_content # We always want to cache Universes, even if they aren't explicitly turned on. @current_user_content = current_user.content(content_types: @activated_content_types + [Universe.name], universe_id: @universe_scope.try(:id)) @@ -84,7 +85,7 @@ class ApplicationController < ActionController::Base end def cache_notifications - @user_notifications = if user_signed_in? + @user_notifications ||= if user_signed_in? current_user.notifications.order('happened_at DESC').limit(100) else [] @@ -92,7 +93,7 @@ class ApplicationController < ActionController::Base end def recently_edited_pages - @recently_edited_pages = if user_signed_in? + @recently_edited_pages ||= if user_signed_in? @current_user_content.values.flatten .sort_by(&:updated_at) .last(50) @@ -103,13 +104,13 @@ class ApplicationController < ActionController::Base end def cache_forums_unread_counts - @unread_threads = if user_signed_in? + @unread_threads ||= if user_signed_in? Thredded::Topic.unread_followed_by(current_user).count else 0 end - @unread_private_messages = if user_signed_in? + @unread_private_messages ||= if user_signed_in? Thredded::PrivateTopic .for_user(current_user) .unread(current_user) @@ -120,7 +121,7 @@ class ApplicationController < ActionController::Base end def cache_contributable_universe_ids - @contributable_universe_ids = if user_signed_in? + @contributable_universe_ids ||= if user_signed_in? Contributor.where(user: current_user).pluck(:universe_id) else [] From 8bad60a773ea823c27e1143d69a96ee41359d79c Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:34:05 -0700 Subject: [PATCH 027/149] rewrite cache_linkable_content_for_each_content_type with far fewer queries --- app/controllers/application_controller.rb | 44 +++++++++++------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 055d7eeb..f59ff07d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -71,6 +71,8 @@ class ApplicationController < ActionController::Base return unless user_signed_in? return if @current_user_content + cache_activated_content_types + # We always want to cache Universes, even if they aren't explicitly turned on. @current_user_content = current_user.content(content_types: @activated_content_types + [Universe.name], universe_id: @universe_scope.try(:id)) @@ -92,7 +94,9 @@ class ApplicationController < ActionController::Base end end - def recently_edited_pages + def cache_recently_edited_pages + cache_current_user_content + @recently_edited_pages ||= if user_signed_in? @current_user_content.values.flatten .sort_by(&:updated_at) @@ -129,32 +133,24 @@ class ApplicationController < ActionController::Base end def cache_linkable_content_for_each_content_type - linkable_classes = Rails.application.config.content_types[:all].map(&:name) & current_user.user_content_type_activators.pluck(:content_type) + cache_contributable_universe_ids + cache_current_user_content + + linkable_classes = @activated_content_types linkable_classes += %w(Document Timeline) - @linkables_cache = {} - @linkables_raw = {} - linkable_classes.each do |class_name| - # class_name = "Character" + @linkables_cache = {} # Cache is list of [[page_name, page_id], [page_name, page_id], ...] + @linkables_raw = {} # Raw is list of objects [#{page}, #{page}, ...] - @linkables_cache[class_name] = current_user - .send("linkable_#{class_name.downcase.pluralize}") - .in_universe(@universe_scope) - - if @content.present? && @content.persisted? - @linkables_cache[class_name] = @linkables_cache[class_name] - .in_universe(@content.universe) - .reject { |content| content.class.name == class_name && content.id == @content.id } - end - - @linkables_raw[class_name] = @linkables_cache[class_name] - .sort_by { |p| p.name.downcase } - .compact - - @linkables_cache[class_name] = @linkables_cache[class_name] - .sort_by { |p| p.name.downcase } - .map { |c| [c.name, c.id] } - .compact + @current_user_content.each do |page_type, content_list| + # We already have our own list of content by the current user in @current_user_content, + # so all we need to grab is pages in contributable universes + @linkables_raw[page_type] = @current_user_content[page_type] \ + + page_type.constantize.where(universe_id: @contributable_universe_ids) end + + # Finally, we want to sort our caches once so we don't need to sort them again anywhere else + @linkables_raw.sort_by! { |page| page.name.downcase }.compact! + @linkables_cache = @linkables_raw.map { |page| [page.name, page.id] } end end From 2eb50f510b1f8c1908760ab3950f3c05d5729715 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:35:57 -0700 Subject: [PATCH 028/149] only query for contributable content if you're a contributor to any universes --- app/controllers/application_controller.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f59ff07d..09f6ad5d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -145,8 +145,16 @@ class ApplicationController < ActionController::Base @current_user_content.each do |page_type, content_list| # We already have our own list of content by the current user in @current_user_content, # so all we need to grab is pages in contributable universes - @linkables_raw[page_type] = @current_user_content[page_type] \ - + page_type.constantize.where(universe_id: @contributable_universe_ids) + @linkables_raw[page_type] = @current_user_content[page_type] + + if @contributable_universe_ids.any? + if page_type == Universe.name + @linkables_raw[page_type] += page_type.constantize.where(id: @contributable_universe_ids) + + else + @linkables_raw[page_type] += page_type.constantize.where(universe_id: @contributable_universe_ids) + end + end end # Finally, we want to sort our caches once so we don't need to sort them again anywhere else From 64715d334b48b2234567b5235ff38f9699c86a27 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:38:42 -0700 Subject: [PATCH 029/149] collapse the loops --- app/controllers/application_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09f6ad5d..7054edb0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -155,10 +155,12 @@ class ApplicationController < ActionController::Base @linkables_raw[page_type] += page_type.constantize.where(universe_id: @contributable_universe_ids) end end - end - # Finally, we want to sort our caches once so we don't need to sort them again anywhere else - @linkables_raw.sort_by! { |page| page.name.downcase }.compact! - @linkables_cache = @linkables_raw.map { |page| [page.name, page.id] } + # Finally, we want to sort our linkables cache once so we don't have to sort it again + @linkables_raw[page_type].sort_by! { |page| page.name.downcase }.compact! + + # Lastly, build our name/id cache as well + @linkables_cache[page_type] = @linkables_raw[page_type].map { |page| [page.name, page.id] } + end end end From 33625960f9f9cb7fc675f7a1abcd6f4a20db878c Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:41:07 -0700 Subject: [PATCH 030/149] tweak cache guards --- app/controllers/application_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7054edb0..a2e07d14 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -53,9 +53,6 @@ class ApplicationController < ActionController::Base end def cache_activated_content_types - @activated_content_types = [] - return unless user_signed_in? - @activated_content_types ||= if user_signed_in? ( # Use config to dictate order, but AND to only include what a user has turned on @@ -67,9 +64,10 @@ class ApplicationController < ActionController::Base end def cache_current_user_content + return if @current_user_content + @current_user_content = {} return unless user_signed_in? - return if @current_user_content cache_activated_content_types From 34b5c753d4d3be4a53aed2d764e829279b02629a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:45:39 -0700 Subject: [PATCH 031/149] reuse linkables cache instead of making new queries --- app/views/content/components/_list_filter_bar.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/content/components/_list_filter_bar.html.erb b/app/views/content/components/_list_filter_bar.html.erb index 88a01d90..12b2c192 100644 --- a/app/views/content/components/_list_filter_bar.html.erb +++ b/app/views/content/components/_list_filter_bar.html.erb @@ -30,7 +30,7 @@
  • <% - linkable_universes_with_this_kind_of_content = current_user.linkable_universes.select do |universe| + linkable_universes_with_this_kind_of_content = @linkables_raw.fetch('Universe', []).select do |universe| @current_user_content[content_type.name].any? { |content| content.universe_id == universe.id } end %> From 832bb924bf7cced20c46bbad71e036c2338bd4a5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:46:31 -0700 Subject: [PATCH 032/149] remove user#linkable_universes --- app/models/users/user.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/users/user.rb b/app/models/users/user.rb index f9f3448a..362cf351 100644 --- a/app/models/users/user.rb +++ b/app/models/users/user.rb @@ -119,10 +119,6 @@ class User < ApplicationRecord @cached_user_contributable_universes ||= Universe.where(id: contributable_universe_ids) end - def linkable_universes - @cached_linkable_universes ||= Universe.where(id: my_universe_ids + contributable_universes) - end - def contributable_universe_ids # TODO: email confirmation needs to happen for data safety / privacy (only verified emails) @contributable_universe_ids ||= Contributor.where('email = ? OR user_id = ?', self.email, self.id).pluck(:universe_id) From 7aed61d812472dab04d39cf14ee484afb3161709 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 01:50:17 -0700 Subject: [PATCH 033/149] freeze AC strings --- app/controllers/application_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a2e07d14..cc15d55d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class ApplicationController < ActionController::Base protect_from_forgery From b2ef0f5981d2fd8c82d0d03a8729b22d97d9369c Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:17:27 -0700 Subject: [PATCH 034/149] helper for recently-created pages cache --- app/controllers/application_controller.rb | 17 +++++++++++++++-- app/controllers/main_controller.rb | 6 +----- app/models/concerns/has_attributes.rb | 1 + 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cc15d55d..ab0710ae 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -93,13 +93,26 @@ class ApplicationController < ActionController::Base end end - def cache_recently_edited_pages + def cache_recently_created_pages(amount=50) + cache_current_user_content + + @recently_created_pages = if user_signed_in? + @current_user_content.values.flatten + .sort_by(&:created_at) + .last(amount) + .reverse + else + [] + end + end + + def cache_recently_edited_pages(amount=50) cache_current_user_content @recently_edited_pages ||= if user_signed_in? @current_user_content.values.flatten .sort_by(&:updated_at) - .last(50) + .last(amount) .reverse else [] diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index bbee013a..95a74c74 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -50,13 +50,9 @@ class MainController < ApplicationController end def recent_content - # todo optimize this / use Attributes return [] if @activated_content_types.nil? - @recently_created_pages = @current_user_content.values.flatten - .sort_by(&:created_at) - .last(50) - .reverse + cache_recently_created_pages end def for_writers diff --git a/app/models/concerns/has_attributes.rb b/app/models/concerns/has_attributes.rb index 00c28e76..612ca305 100644 --- a/app/models/concerns/has_attributes.rb +++ b/app/models/concerns/has_attributes.rb @@ -180,6 +180,7 @@ module HasAttributes end end + # All of these helpers are spooky and rife for N+1s def name_field category_ids = AttributeCategory.where( user_id: user_id, From 1b99bdf9dca41c4cbdaa31be1d10f3a690faef81 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:19:21 -0700 Subject: [PATCH 035/149] remove unnecessary queries --- app/controllers/main_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 95a74c74..255f1492 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -50,9 +50,6 @@ class MainController < ApplicationController end def recent_content - return [] if @activated_content_types.nil? - - cache_recently_created_pages end def for_writers From fb8e298948f76c6e2012685391fc5f6041b0b9d3 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:21:00 -0700 Subject: [PATCH 036/149] add header to recent edits stream --- app/views/main/recent_content.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/main/recent_content.html.erb b/app/views/main/recent_content.html.erb index a3014da2..25f47f98 100644 --- a/app/views/main/recent_content.html.erb +++ b/app/views/main/recent_content.html.erb @@ -1,5 +1,9 @@ <%# TODO: put this in more of a timeline design %>
    +
    +
    +
    Your recent worldbuilding activity
    +
    <% @recently_edited_pages.each do |page| %> <% action = page.created_at === page.updated_at ? 'Created' : 'Updated' %> <% klass = page.is_a?(ContentPage) ? content_class_from_name(page.page_type) : page.class %> From f23522e8b91f87e164e5e782cb008df48992a22c Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:26:29 -0700 Subject: [PATCH 037/149] reuse user method for cache --- app/controllers/application_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ab0710ae..bcb421cd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -46,6 +46,8 @@ class ApplicationController < ActionController::Base # Cache some super-common stuff we need for every page. For example, content lists for the side nav. This is a catch-all for most pages that render # UI, but methods are also free to skip this filter and call the individual cache methods they need instead. def cache_most_used_page_information + return unless user_signed_in? + cache_activated_content_types cache_current_user_content cache_notifications @@ -138,7 +140,7 @@ class ApplicationController < ActionController::Base def cache_contributable_universe_ids @contributable_universe_ids ||= if user_signed_in? - Contributor.where(user: current_user).pluck(:universe_id) + current_user.contributable_universe_ids else [] end From 3db83d9e75af757560a1a82d92bce3ded488a024 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:27:04 -0700 Subject: [PATCH 038/149] reuse cached universes to fetch ids --- app/models/users/user.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/users/user.rb b/app/models/users/user.rb index 362cf351..a4750103 100644 --- a/app/models/users/user.rb +++ b/app/models/users/user.rb @@ -112,7 +112,9 @@ class User < ApplicationRecord has_many :application_integrations def my_universe_ids - @cached_universe_ids ||= universes.pluck(:id) + cache_current_user_content + + @cached_universe_ids = @current_user_content.fetch('Universe', []).map(&:id) end def contributable_universes From dd969ba39fe77d1e20dbbacaa43d935be1d72da4 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:27:41 -0700 Subject: [PATCH 039/149] scratch that, lol --- app/models/users/user.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/users/user.rb b/app/models/users/user.rb index a4750103..362cf351 100644 --- a/app/models/users/user.rb +++ b/app/models/users/user.rb @@ -112,9 +112,7 @@ class User < ApplicationRecord has_many :application_integrations def my_universe_ids - cache_current_user_content - - @cached_universe_ids = @current_user_content.fetch('Universe', []).map(&:id) + @cached_universe_ids ||= universes.pluck(:id) end def contributable_universes From 7aafbdd25d5af9136809e5de51b75f247aa71cf5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:36:17 -0700 Subject: [PATCH 040/149] freeze strings in ContentController --- app/controllers/content_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index fa7eafec..b6743ee2 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ContentController < ApplicationController # todo we should probably spin off an Api::ContentController for #api_sort and anything else api-wise we need From 54b1c43e34be82d1027e1df298461e55302c928b Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:43:45 -0700 Subject: [PATCH 041/149] skip ui cache on content api calls --- app/controllers/content_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index b6743ee2..6c9893d2 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -1,11 +1,15 @@ # frozen_string_literal: true +# TODO: we should probably spin off an Api::ContentController for #api_sort and anything else +# api-wise we need class ContentController < ApplicationController - # todo we should probably spin off an Api::ContentController for #api_sort and anything else api-wise we need - before_action :authenticate_user!, except: [:show, :changelog, :api_sort] \ + Rails.application.config.content_types[:all_non_universe].map { |type| type.name.downcase.pluralize.to_sym } + skip_before_action :cache_most_used_page_information, only: [ + :name_field_update, :text_field_update, :tags_field_update, :universe_field_update + ] + before_action :migrate_old_style_field_values, only: [:show, :edit] before_action :cache_linkable_content_for_each_content_type, only: [:new, :edit, :index] From f977c586667817f72a5bc8d11d98b043c28b8494 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:47:08 -0700 Subject: [PATCH 042/149] simplify valid_content_types usage --- app/controllers/content_controller.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 6c9893d2..206506ef 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -78,7 +78,7 @@ class ContentController < ApplicationController def show content_type = content_type_from_controller(self.class) - return redirect_to(root_path, notice: "That page doesn't exist!") unless valid_content_types.map(&:name).include?(content_type.name) + return redirect_to(root_path, notice: "That page doesn't exist!") unless valid_content_types.include?(content_type.name) @content = content_type.find_by(id: params[:id]) return redirect_to(root_path, notice: "You don't have permission to view that content.") if @content.nil? @@ -295,7 +295,7 @@ class ContentController < ApplicationController def changelog content_type = content_type_from_controller(self.class) - return redirect_to root_path unless valid_content_types.map(&:name).include?(content_type.name) + return redirect_to root_path unless valid_content_types.include?(content_type.name) @content = content_type.find_by(id: params[:id]) return redirect_to(root_path, notice: "You don't have permission to view that content.") if @content.nil? @serialized_content = ContentSerializer.new(@content) @@ -461,7 +461,7 @@ class ContentController < ApplicationController # We also need to update the cached `name` field on the content page itself entity_type = entity_params.fetch(:entity_type) - raise "Invalid entity type: #{entity_params.fetch(:entity_type)}" unless valid_content_types.map(&:name).include?(entity_params.fetch('entity_type')) + raise "Invalid entity type: #{entity_params.fetch(:entity_type)}" unless valid_content_types.include?(entity_params.fetch('entity_type')) entity = entity_type.constantize.find_by(id: entity_params.fetch(:entity_id).to_i) entity.update(name: field_params.fetch('value', '')) end @@ -503,7 +503,7 @@ class ContentController < ApplicationController end def tags_field_update - return unless valid_content_types.map(&:name).include?(entity_params.fetch('entity_type')) + return unless valid_content_types.include?(entity_params.fetch('entity_type')) @attribute_field = AttributeField.find_by(id: params[:field_id].to_i) attribute_value = @attribute_field.attribute_values.order('created_at desc').find_or_initialize_by(entity_params) @@ -518,7 +518,7 @@ class ContentController < ApplicationController end def universe_field_update - return unless valid_content_types.map(&:name).include?(entity_params.fetch('entity_type')) + return unless valid_content_types.include?(entity_params.fetch('entity_type')) @attribute_field = AttributeField.find_by(id: params[:field_id].to_i) attribute_value = @attribute_field.attribute_values.order('created_at desc').find_or_initialize_by(entity_params) @@ -586,7 +586,7 @@ class ContentController < ApplicationController end def valid_content_types - Rails.application.config.content_types[:all] + Rails.application.config.content_type_names[:all] end def initialize_object @@ -662,7 +662,7 @@ class ContentController < ApplicationController def set_attributes_content_type @content_type = params[:content_type] # todo make this a before_action load_content_type - unless valid_content_types.map { |c| c.name.downcase }.include?(@content_type) + unless valid_content_types.map(&:downcase).include?(@content_type) raise "Invalid content type on attributes customization page: #{@content_type}" end @content_type_class = @content_type.titleize.constantize @@ -677,7 +677,7 @@ class ContentController < ApplicationController entity_page_type = entity_params.fetch(:entity_type) entity_page_id = entity_params.fetch(:entity_id) - return unless valid_content_types.map(&:name).include?(entity_page_type) + return unless valid_content_types.include?(entity_page_type) @entity = entity_page_type.constantize.find_by(id: entity_page_id) end From 4a48dc025333f3cb6de8643c9c8ee6f61ba2e44b Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 11:57:06 -0700 Subject: [PATCH 043/149] standardize @current_user_content vs @linkables --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bcb421cd..5e4d67dd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -80,10 +80,10 @@ class ApplicationController < ActionController::Base # Likewise, we should also always cache Timelines & Documents if @universe_scope @current_user_content['Timeline'] = current_user.timelines.where(universe_id: @universe_scope.try(:id)).to_a - @current_user_content['Document'] = current_user.linkable_documents.includes([:user]).where(universe_id: @universe_scope.try(:id)).order('updated_at DESC').to_a + @current_user_content['Document'] = current_user.documents.includes([:user]).where(universe_id: @universe_scope.try(:id)).order('updated_at DESC').to_a else @current_user_content['Timeline'] = current_user.timelines.to_a - @current_user_content['Document'] = current_user.linkable_documents.includes([:user]).order('updated_at DESC').to_a + @current_user_content['Document'] = current_user.documents.includes([:user]).order('updated_at DESC').to_a end end From 512bff2aae3a003712cea4970f2352066a76531a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 12:02:00 -0700 Subject: [PATCH 044/149] move the old doc user includes --- app/controllers/application_controller.rb | 4 ++-- app/models/users/user.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5e4d67dd..b15d1142 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -80,10 +80,10 @@ class ApplicationController < ActionController::Base # Likewise, we should also always cache Timelines & Documents if @universe_scope @current_user_content['Timeline'] = current_user.timelines.where(universe_id: @universe_scope.try(:id)).to_a - @current_user_content['Document'] = current_user.documents.includes([:user]).where(universe_id: @universe_scope.try(:id)).order('updated_at DESC').to_a + @current_user_content['Document'] = current_user.documents.where(universe_id: @universe_scope.try(:id)).order('updated_at DESC').to_a else @current_user_content['Timeline'] = current_user.timelines.to_a - @current_user_content['Document'] = current_user.documents.includes([:user]).order('updated_at DESC').to_a + @current_user_content['Document'] = current_user.documents.order('updated_at DESC').to_a end end diff --git a/app/models/users/user.rb b/app/models/users/user.rb index 362cf351..9c7583af 100644 --- a/app/models/users/user.rb +++ b/app/models/users/user.rb @@ -152,7 +152,7 @@ class User < ApplicationRecord universe_id IN (#{(my_universe_ids + contributable_universe_ids + [-1]).uniq.join(',')}) OR (universe_id IS NULL AND user_id = #{self.id.to_i}) - """) + """).includes([:user]) end def linkable_timelines From a6d169fa92f0c009a21343265b4624190bce03d8 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 13:38:25 -0700 Subject: [PATCH 045/149] this removes ~100 field queries for default character template, oof --- app/models/concerns/has_attributes.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/models/concerns/has_attributes.rb b/app/models/concerns/has_attributes.rb index 612ca305..b9aa3388 100644 --- a/app/models/concerns/has_attributes.rb +++ b/app/models/concerns/has_attributes.rb @@ -60,13 +60,19 @@ module HasAttributes end category.save! if user && category.new_record? + fields_list = category.attribute_fields.with_deleted.where(user: user) category.attribute_fields << details[:attributes].map do |field| - af_field = category.attribute_fields.with_deleted.find_or_initialize_by( - # label: field[:label], - old_column_source: field[:name], - user: user, - field_type: field[:field_type].presence || "text_area" - ) + af_field = fields_list.detect do |persisted_field| + persisted_field.old_column_source == field[:name] && + persisted_field.field_type == field[:field_type].presence || "text_area" + end + if af_field.nil? + af_field = category.attribute_fields.new( + old_column_source: field[:name], + user: user, + field_type: field[:field_type].presence || "text_area" + ) + end if af_field.label.nil? af_field.label = field[:label] end From 89294471f800f22e892a1e9df867d7e3a0db15b1 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 13:40:35 -0700 Subject: [PATCH 046/149] codesmell todo --- app/models/concerns/has_attributes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/concerns/has_attributes.rb b/app/models/concerns/has_attributes.rb index b9aa3388..1a710230 100644 --- a/app/models/concerns/has_attributes.rb +++ b/app/models/concerns/has_attributes.rb @@ -42,6 +42,8 @@ module HasAttributes end def self.attribute_categories(user, show_hidden: false) + # TODO: this is a code smell; we should probably either be whitelisting or fixing whatever is calling + # this with the wrong models return [] if ['attribute_category', 'attribute_field'].include?(content_name) # Cache the result in case we call this function multiple times this request From 08b86f17f094b82d72d5e9083cff5f3923c2d0f8 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 13:43:21 -0700 Subject: [PATCH 047/149] kill N+1s for loading AttributeCategories from template also --- app/models/concerns/has_attributes.rb | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app/models/concerns/has_attributes.rb b/app/models/concerns/has_attributes.rb index 1a710230..d2fe1709 100644 --- a/app/models/concerns/has_attributes.rb +++ b/app/models/concerns/has_attributes.rb @@ -49,12 +49,20 @@ module HasAttributes # Cache the result in case we call this function multiple times this request @cached_attribute_categories_for_this_content = begin # Always include the flatfile categories (but create AR versions if they don't exist) + categories_list = AttributeCategory.with_deleted.where(user: user) categories = YAML.load_file(Rails.root.join('config', 'attributes', "#{content_name}.yml")).map do |category_name, details| - category = ::AttributeCategory.with_deleted.find_or_initialize_by( - entity_type: self.content_name, - name: category_name.to_s, - user: user - ) + category = categories_list.detect do |persisted_category| + persisted_category.entity_type == self.content_name && + persisted_category.name == category_name.to_s + end + if category.nil? + category = AttributeCategory.new( + entity_type: self.content_name, + name: category_name.to_s, + user: user + ) + end + # Default new categories to some sane defaults unless category.persisted? category.icon = details[:icon] @@ -66,13 +74,13 @@ module HasAttributes category.attribute_fields << details[:attributes].map do |field| af_field = fields_list.detect do |persisted_field| persisted_field.old_column_source == field[:name] && - persisted_field.field_type == field[:field_type].presence || "text_area" + persisted_field.field_type == field[:field_type].presence || "text_area" end if af_field.nil? af_field = category.attribute_fields.new( old_column_source: field[:name], - user: user, - field_type: field[:field_type].presence || "text_area" + user: user, + field_type: field[:field_type].presence || "text_area" ) end if af_field.label.nil? From d8b7e3b260d4591fba9200b7410c04a2bc114859 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 14:12:04 -0700 Subject: [PATCH 048/149] remove yet another set of n+1 --- app/models/concerns/has_attributes.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/has_attributes.rb b/app/models/concerns/has_attributes.rb index d2fe1709..b7a07108 100644 --- a/app/models/concerns/has_attributes.rb +++ b/app/models/concerns/has_attributes.rb @@ -49,7 +49,8 @@ module HasAttributes # Cache the result in case we call this function multiple times this request @cached_attribute_categories_for_this_content = begin # Always include the flatfile categories (but create AR versions if they don't exist) - categories_list = AttributeCategory.with_deleted.where(user: user) + categories_list = AttributeCategory.with_deleted.where(user: user).to_a + full_fields_list = AttributeField.with_deleted.where(user: user, attribute_category_id: categories_list.map(&:id)) categories = YAML.load_file(Rails.root.join('config', 'attributes', "#{content_name}.yml")).map do |category_name, details| category = categories_list.detect do |persisted_category| persisted_category.entity_type == self.content_name && @@ -70,7 +71,9 @@ module HasAttributes end category.save! if user && category.new_record? - fields_list = category.attribute_fields.with_deleted.where(user: user) + fields_list = full_fields_list.select do |field| + field.attribute_category_id == category.id + end category.attribute_fields << details[:attributes].map do |field| af_field = fields_list.detect do |persisted_field| persisted_field.old_column_source == field[:name] && From 010f57c9a21a45059a88180958bd85cb7b5600c4 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 14:31:51 -0700 Subject: [PATCH 049/149] skip ui cache on document update --- app/controllers/documents_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 4ded2037..e961943e 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -4,6 +4,8 @@ class DocumentsController < ApplicationController # todo Uh, this is a hack. The CSRF token on document editor model to add entities is being rejected... for whatever reason. skip_before_action :verify_authenticity_token, only: [:link_entity] + skip_before_action :cache_most_used_page_information, only: [:update] + before_action :set_document, only: [:show, :analysis, :plaintext, :queue_analysis, :edit, :destroy] before_action :set_sidenav_expansion, except: [:plaintext] before_action :set_navbar_color, except: [:plaintext] From 8bad87b63a177037e8a1183a06d2983867b3a2eb Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 14:33:03 -0700 Subject: [PATCH 050/149] doc update readability --- app/controllers/documents_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index e961943e..a1f5b731 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -183,21 +183,21 @@ class DocumentsController < ApplicationController def update document = Document.with_deleted.find_or_initialize_by(id: params[:id]) - d_params = document_params.clone # TODO: why are we duplicating the params here? unless document.updatable_by?(current_user) redirect_to(dashboard_path, notice: "You don't have permission to do that!") return end - # Only queue document mentions for analysis if the document body has changed - DocumentMentionJob.perform_later(document.id) if d_params.key?(:body) - # We can't pass actual-nil from HTML (for no universe), so we pass a string instead and convert it back here. + d_params = document_params.clone if d_params.fetch(:universe_id, nil) == "nil" d_params[:universe_id] = nil end + # Only queue document mentions for analysis if the document body has changed + DocumentMentionJob.perform_later(document.id) if d_params.key?(:body) + update_page_tags(document) if document_tag_params if document.update(d_params) From a60ddb81f1355bc8df1dcd68cd8430bef7a08de1 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 16:21:06 -0700 Subject: [PATCH 051/149] restyle icons for year in review report --- app/assets/stylesheets/layout.scss | 1 + app/views/data/review_year.html.erb | 35 ++++++++++++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index adaf9eeb..1f974cc2 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -9,4 +9,5 @@ .card-panel-title { font-size: 1.3em; font-weight: bold; + margin-top: 0.5em; } \ No newline at end of file diff --git a/app/views/data/review_year.html.erb b/app/views/data/review_year.html.erb index 2d4a257b..b086f7ca 100644 --- a/app/views/data/review_year.html.erb +++ b/app/views/data/review_year.html.erb @@ -14,7 +14,7 @@

    - cake + cake You signed up to Notebook.ai on <%= current_user.created_at.strftime("%B %d of this year, a very fine %A") %>!

    @@ -32,7 +32,7 @@
    - + <%= @earliest_page.class.icon %> It all started with <%= @earliest_page.name %>... @@ -45,9 +45,11 @@
    -
    +
    - <%= image_tag @earliest_page.random_image_including_private %> + <%= link_to @earliest_page do %> + <%= image_tag @earliest_page.random_image_including_private %> + <% end %>
    @@ -75,8 +77,8 @@
    <%= render partial: 'content/components/parallax_header', locals: { content_type: 'Universe', content_class: Universe, image_only: true } %>
    + <%= Universe.icon %>

    - <%= Universe.icon %> You started creating <%= pluralize @created_content['Universe'].count, 'new universe' %> in <%= @year %>!

    @@ -103,8 +105,8 @@
    + dashboard
    - dashboard In your worlds, you created <%= pluralize @total_created_non_universe_content, 'notebook pages' %> this year! @@ -138,7 +140,10 @@
    - You also uploaded <%= pluralize @created_content['ImageUpload'].count, 'image' %> to your notebook pages this year! +

    + upload + You also uploaded <%= pluralize @created_content['ImageUpload'].count, 'image' %> to your notebook pages this year! +

    @@ -153,8 +158,8 @@ <%= render partial: 'content/components/parallax_header', locals: { content_type: 'Document', content_class: Document, image_only: true } %>
    + <%= Document.icon %>
    - <%= Document.icon %> You started writing <%= pluralize @created_content['Document'].count, 'document' %> in <%= @year %>!

    @@ -164,11 +169,11 @@ <% @created_content['Document'].each do |document| %>

    - <%= link_to edit_document_path(document) do %> -
    - <%= Document.icon %> - <%= document.title %> -
    + <%= link_to document_path(document) do %> +
    + <%= Document.icon %> + <%= document.title %> +
    <% end %>
    <% end %> @@ -273,14 +278,14 @@
    + date_range
    - date_range <%= @year %> was a productive year for you!

    Thanks for spending it on Notebook.ai. I can't wait to see what you accomplish in <%= @year + 1 %>! :)

    -

    +

    — Andrew

    From 56cb9a60484f16cea897b9229e1cc34f75763b03 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Aug 2021 18:52:46 -0700 Subject: [PATCH 052/149] remove animate-rails --- Gemfile | 1 - Gemfile.lock | 3 --- app/assets/stylesheets/application.css | 1 - 3 files changed, 5 deletions(-) diff --git a/Gemfile b/Gemfile index 0a253993..eb79aec0 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,6 @@ gem 'paranoia' # Javascript gem 'coffee-rails' gem 'rails-jquery-autocomplete' -gem 'animate-rails' gem 'webpacker' gem 'react-rails' diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..68790089 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,8 +108,6 @@ GEM activerecord (>= 4.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - animate-rails (1.0.10) - rails authority (3.3.0) activesupport (>= 3.0.0) autoprefixer-rails (9.8.4) @@ -1545,7 +1543,6 @@ PLATFORMS DEPENDENCIES active_storage_validations acts_as_list - animate-rails authority aws-sdk (~> 3.0) aws-sdk-s3 diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 670b96cc..e0b1691b 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -13,7 +13,6 @@ *= require font-awesome *= require medium-editor/medium-editor *= require medium-editor/themes/beagle - *= require animate *= require tribute *= require_tree . */ From 7ceb687ffff283c7cd80bd5d95c9c74f3093a0ec Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 8 Aug 2021 12:02:20 -0700 Subject: [PATCH 053/149] secure universe session var --- app/controllers/application_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b15d1142..8aa95d1d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,9 +35,13 @@ class ApplicationController < ActionController::Base def set_universe_scope if user_signed_in? && session.key?(:universe_id) - # We generally trust that once a universe is set in the session, we don't need to keep re-verifying on every page load that the user - # still has access to that universe. - @universe_scope = Universe.find_by(id: session[:universe_id]) + cache_contributable_universe_ids + + if @contributable_universe_ids.include?(session[:universe_id]) + @universe_scope = Universe.find_by(id: session[:universe_id]) + else + @universe_scope = nil + end else @universe_scope = nil end From 3f18f8c6eea558ef6f99a62447ad127ef7a00c69 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 8 Aug 2021 15:47:48 -0700 Subject: [PATCH 054/149] wip before going down the ContentPage rabbit hole --- app/controllers/content_controller.rb | 2 +- app/models/concerns/has_content.rb | 2 +- app/models/page_types/content_page.rb | 8 ++++++++ app/services/temporary_field_migration_service.rb | 1 + app/views/api/api_docs/index.html.erb | 4 ++-- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 206506ef..cdfab67f 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -7,7 +7,7 @@ class ContentController < ApplicationController + Rails.application.config.content_types[:all_non_universe].map { |type| type.name.downcase.pluralize.to_sym } skip_before_action :cache_most_used_page_information, only: [ - :name_field_update, :text_field_update, :tags_field_update, :universe_field_update + :name_field_update, :text_field_update, :tags_field_update, :universe_field_update, :api_sort ] before_action :migrate_old_style_field_values, only: [:show, :edit] diff --git a/app/models/concerns/has_content.rb b/app/models/concerns/has_content.rb index eff6dd03..c619d6d0 100644 --- a/app/models/concerns/has_content.rb +++ b/app/models/concerns/has_content.rb @@ -27,7 +27,7 @@ module HasContent ) return {} if content_types.empty? - polymorphic_content_fields = [:id, :name, :page_type, :user_id, :created_at, :updated_at, :deleted_at, :archived_at, :privacy] + polymorphic_content_fields = [:id, :name, :favorite, :page_type, :user_id, :created_at, :updated_at, :deleted_at, :archived_at, :privacy] where_conditions = page_scoping.map { |key, value| "#{key} = #{value}" }.join(' AND ') + ' AND deleted_at IS NULL AND archived_at IS NULL' sql = content_types.uniq.map do |page_type| diff --git a/app/models/page_types/content_page.rb b/app/models/page_types/content_page.rb index 41581e4a..12e265a0 100644 --- a/app/models/page_types/content_page.rb +++ b/app/models/page_types/content_page.rb @@ -17,4 +17,12 @@ class ContentPage < ApplicationRecord def text_color self.page_type.constantize.text_color end + + def favorite? + !!favorite + end + + def view_path + + end end diff --git a/app/services/temporary_field_migration_service.rb b/app/services/temporary_field_migration_service.rb index e7b0e969..cdf4b19c 100644 --- a/app/services/temporary_field_migration_service.rb +++ b/app/services/temporary_field_migration_service.rb @@ -11,6 +11,7 @@ class TemporaryFieldMigrationService < Service def self.migrate_fields_for_content(content_model, user, force: false) return unless content_model.present? && user.present? return unless content_model.user == user + return if content_model.is_a?(ContentPage) return if !force && content_model.persisted? && content_model.created_at > 'May 1, 2018'.to_datetime return if !!content_model.columns_migrated_from_old_style? diff --git a/app/views/api/api_docs/index.html.erb b/app/views/api/api_docs/index.html.erb index 62964333..7481809a 100644 --- a/app/views/api/api_docs/index.html.erb +++ b/app/views/api/api_docs/index.html.erb @@ -100,7 +100,7 @@
    - Gain full access to + Gain full access to millions of <% Rails.application.config.content_types[:all_non_universe].each do |type| %> <%= type.name.downcase.pluralize %>, <% end %> @@ -110,7 +110,7 @@

    After a user authenticates your application, you'll have full access to integrate their worldbuilding pages into your app. - You can show them their characters, let them edit one of their existing creatures, pin their towns and landmarks to your maps, + You can show them their characters, let them import pictures from their locations, pin their towns and landmarks to your maps, create new items, and more — all without leaving your app.


    From 4e782bf55e46a9dae0b97b9f14ad935b6ad7acea Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 8 Aug 2021 17:11:37 -0700 Subject: [PATCH 055/149] include contributed content in contributable content --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8aa95d1d..762aced0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -144,7 +144,7 @@ class ApplicationController < ActionController::Base def cache_contributable_universe_ids @contributable_universe_ids ||= if user_signed_in? - current_user.contributable_universe_ids + current_user.contributable_universe_ids + @current_user_content.fetch('Universe', []).map(&:id) else [] end From 0d5e6db79afafff85003e22c5de363fcd9965278 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 8 Aug 2021 17:37:28 -0700 Subject: [PATCH 056/149] rewrite linkable content caching again, to exclude current_user_contnet ids --- app/controllers/application_controller.rb | 18 +++++++++++++++--- app/models/concerns/has_content.rb | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 762aced0..15eee97f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -162,15 +162,27 @@ class ApplicationController < ActionController::Base @current_user_content.each do |page_type, content_list| # We already have our own list of content by the current user in @current_user_content, - # so all we need to grab is pages in contributable universes + # so all we need to grab is additional pages in contributable universes @linkables_raw[page_type] = @current_user_content[page_type] if @contributable_universe_ids.any? + existing_page_ids = @linkables_raw[page_type].map(&:id) + if page_type == Universe.name - @linkables_raw[page_type] += page_type.constantize.where(id: @contributable_universe_ids) + universes_to_add = page_type.constantize.where(id: @contributable_universe_ids) + .where.not(id: existing_page_ids) + universes_to_add.each do |page_data| + filtered_page_data = page_data.attributes.slice(*ContentPage.polymorphic_content_fields.map(&:to_s)) + @linkables_raw[page_type].push ContentPage.new(filtered_page_data) + end else - @linkables_raw[page_type] += page_type.constantize.where(universe_id: @contributable_universe_ids) + pages_to_add = page_type.constantize.where(universe_id: @contributable_universe_ids) + .where.not(id: existing_page_ids) + pages_to_add.each do |page_data| + filtered_page_data = page_data.attributes.slice(*ContentPage.polymorphic_content_fields.map(&:to_s)) + @linkables_raw[page_type].push ContentPage.new(filtered_page_data) + end end end diff --git a/app/models/concerns/has_content.rb b/app/models/concerns/has_content.rb index c619d6d0..b5b4b936 100644 --- a/app/models/concerns/has_content.rb +++ b/app/models/concerns/has_content.rb @@ -27,7 +27,7 @@ module HasContent ) return {} if content_types.empty? - polymorphic_content_fields = [:id, :name, :favorite, :page_type, :user_id, :created_at, :updated_at, :deleted_at, :archived_at, :privacy] + polymorphic_content_fields = ContentPage.polymorphic_content_fields where_conditions = page_scoping.map { |key, value| "#{key} = #{value}" }.join(' AND ') + ' AND deleted_at IS NULL AND archived_at IS NULL' sql = content_types.uniq.map do |page_type| @@ -67,7 +67,7 @@ module HasContent ) # todo we can't select for universe_id here which kind of sucks, so we need to research 1) the repercussions, 2) what to do instead - polymorphic_content_fields = [:id, :name, :page_type, :user_id, :created_at, :updated_at, :deleted_at, :archived_at, :privacy] + polymorphic_content_fields = ContentPage.polymorphic_content_fields where_conditions = page_scoping.map { |key, value| "#{key} = #{value}" }.join(' AND ') + ' AND deleted_at IS NULL AND archived_at IS NULL' sql = content_types.uniq.map do |page_type| From b12900a59b6b3e213999376c5cdae4b548aadcab Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 8 Aug 2021 17:49:19 -0700 Subject: [PATCH 057/149] clean up previous commit --- app/controllers/application_controller.rb | 25 ++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 15eee97f..2207a0a5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -168,21 +168,18 @@ class ApplicationController < ActionController::Base if @contributable_universe_ids.any? existing_page_ids = @linkables_raw[page_type].map(&:id) - if page_type == Universe.name - universes_to_add = page_type.constantize.where(id: @contributable_universe_ids) - .where.not(id: existing_page_ids) - universes_to_add.each do |page_data| - filtered_page_data = page_data.attributes.slice(*ContentPage.polymorphic_content_fields.map(&:to_s)) - @linkables_raw[page_type].push ContentPage.new(filtered_page_data) - end - + pages_to_add = if page_type == Universe.name + page_type.constantize.where(id: @contributable_universe_ids) + .where.not(id: existing_page_ids) else - pages_to_add = page_type.constantize.where(universe_id: @contributable_universe_ids) - .where.not(id: existing_page_ids) - pages_to_add.each do |page_data| - filtered_page_data = page_data.attributes.slice(*ContentPage.polymorphic_content_fields.map(&:to_s)) - @linkables_raw[page_type].push ContentPage.new(filtered_page_data) - end + page_type.constantize.where(universe_id: @contributable_universe_ids) + .where.not(id: existing_page_ids) + end + + filtered_fields = ContentPage.polymorphic_content_fields.map(&:to_s) + pages_to_add.each do |page_data| + filtered_page_data = page_data.attributes.slice(*filtered_fields) + @linkables_raw[page_type].push ContentPage.new(filtered_page_data) end end From 5c972738db1686748f65671a98ff7b2544db73ea Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 9 Aug 2021 01:29:58 -0700 Subject: [PATCH 058/149] WIP migrating to wide ContentPage usage --- app/authorizers/content_page_authorizer.rb | 48 ++++++++++++++++++++++ app/controllers/application_controller.rb | 1 + app/controllers/content_controller.rb | 44 ++++++++++++-------- app/models/concerns/has_content.rb | 32 ++++++++++++++- app/models/page_types/content_page.rb | 15 +++++++ app/services/permission_service.rb | 6 ++- app/views/content/list/_cards.html.erb | 13 ++---- 7 files changed, 131 insertions(+), 28 deletions(-) create mode 100644 app/authorizers/content_page_authorizer.rb diff --git a/app/authorizers/content_page_authorizer.rb b/app/authorizers/content_page_authorizer.rb new file mode 100644 index 00000000..3bc57016 --- /dev/null +++ b/app/authorizers/content_page_authorizer.rb @@ -0,0 +1,48 @@ +class ContentPageAuthorizer < CoreContentAuthorizer + def self.creatable_by?(user) + return false unless user.present? + return false if ENV.key?('CONTENT_BLACKLIST') && ENV['CONTENT_BLACKLIST'].split(',').include?(user.email) + + if resource.page_type == 'Universe' + return true if PermissionService.user_has_fewer_owned_universes_than_plan_limit?(user: user) + + else + is_premium_page = Rails.application.config.content_types[:premium].include?(resource.page_type) + return true if !is_premium_page + return true if is_premium_page && PermissionService.user_is_on_premium_plan?(user: user) + end + + return false + end + + def readable_by?(user) + return true if PermissionService.content_is_public?(content: resource) + return true if PermissionService.user_owns_content?(user: user, content: resource) + + if resource.page_type == 'Universe' + return true if PermissionService.user_can_contribute_to_universe?(user: user, universe: resource) + else + return true if PermissionService.user_can_contribute_to_containing_universe?(user: user, content: resource) + end + + return false + end + + def updatable_by?(user) + return true if PermissionService.user_owns_content?(user: user, content: resource) + + if resource.page_type == 'Universe' + return true if PermissionService.user_can_contribute_to_universe?(user: user, universe: resource) + else + return true if PermissionService.user_can_contribute_to_containing_universe?(user: user, content: resource) + end + + return false + end + + def deletable_by?(user) + [ + PermissionService.user_owns_content?(user: user, content: resource) + ].any? + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2207a0a5..cc98399c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -177,6 +177,7 @@ class ApplicationController < ActionController::Base end filtered_fields = ContentPage.polymorphic_content_fields.map(&:to_s) + filtered_fields.push 'universe_id' unless page_type == Universe.name pages_to_add.each do |page_data| filtered_page_data = page_data.attributes.slice(*filtered_fields) @linkables_raw[page_type].push ContentPage.new(filtered_page_data) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index cdfab67f..d74d44df 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -21,33 +21,45 @@ class ContentController < ApplicationController before_action :set_sidenav_expansion, except: [:api_sort] def index + cache_linkable_content_for_each_content_type + @content_type_class = content_type_from_controller(self.class) pluralized_content_name = @content_type_class.name.downcase.pluralize @page_title = "My #{pluralized_content_name}" # Create the default fields for this user if they don't have any already + # TODO: uh, this probably doesn't belong here! @content_type_class.attribute_categories(current_user) - if @universe_scope.present? && @content_type_class != Universe - @content = @universe_scope.send(pluralized_content_name) - .includes(:page_tags, :image_uploads) - .unarchived + # Linkables cache is already scoped per-universe, includes contributor pages + @content = @linkables_raw.fetch(@content_type_class.name, []) - @show_scope_notice = true - else - @content = ( - current_user.send(pluralized_content_name).unarchived.includes(:page_tags, :image_uploads) + - current_user.send("contributable_#{pluralized_content_name}").unarchived.includes(:page_tags, :image_uploads) - ) + @show_scope_notice = @universe_scope.present? && content_type_class != Universe - if @content_type_class != Universe - my_universe_ids = current_user.universes.pluck(:id) - @content.concat(@content_type_class.where(universe_id: my_universe_ids).unarchived) - end - end + # if @universe_scope.present? && @content_type_class != Universe + # # Linkables cache is already scoped per-universe - @content = @content.to_a.flatten.uniq + # @content = @current_user_content.fetch(@content_type_class.name, []) + # .select { |page| page.universe_id == @universe_scope.id } + + # @content = @universe_scope.send(pluralized_content_name) + # .includes(:page_tags, :image_uploads) + # .unarchived + + # @show_scope_notice = true + # else + # @content = ( + # current_user.send(pluralized_content_name).unarchived.includes(:page_tags, :image_uploads) + + # current_user.send("contributable_#{pluralized_content_name}").unarchived.includes(:page_tags, :image_uploads) + # ) + + # if @content_type_class != Universe + # my_universe_ids = current_user.universes.pluck(:id) + # @content.concat(@content_type_class.where(universe_id: my_universe_ids).unarchived) + # end + # end + # @content = @content.to_a.flatten.uniq # Filters @page_tags = PageTag.where( diff --git a/app/models/concerns/has_content.rb b/app/models/concerns/has_content.rb index b5b4b936..7951d542 100644 --- a/app/models/concerns/has_content.rb +++ b/app/models/concerns/has_content.rb @@ -16,16 +16,46 @@ module HasContent has_many :attribute_categories has_many :attribute_values, class_name: 'Attribute', dependent: :destroy + def content_with_multiple_queries( + content_types: Rails.application.config.content_type_names[:all], + page_scoping: { user_id: self.id }, + universe_id: nil + ) + @content_by_page_type = {} + content_types.each do |content_type| + type_specific_fields = ContentPage.polymorphic_content_fields + type_specific_fields.push 'universe_id' unless content_type == 'Universe' + + pages_of_this_type = content_type.constantize + .where(page_scoping) + .select(type_specific_fields) + + if content_type != 'Universe' && universe_id.present? + pages_of_this_type = pages_of_this_type.where(universe_id: universe_id) + end + + @content_by_page_type[content_type] = [] + pages_of_this_type.each do |page_data| + @content_by_page_type[content_type].push ContentPage.new(page_data.attributes) + end + end + + @content_by_page_type + end + # { # characters: [...], # locations: [...] # } def content( - content_types: Rails.application.config.content_types[:all].map(&:name), + content_types: Rails.application.config.content_type_names[:all], page_scoping: { user_id: self.id }, universe_id: nil ) + return content_with_multiple_queries(content_types: content_types, page_scoping: page_scoping, universe_id: universe_id) + return {} if content_types.empty? + # TODO: we should return early if we already have @content_by_page_type!!! polymorphic_content_fields = ContentPage.polymorphic_content_fields where_conditions = page_scoping.map { |key, value| "#{key} = #{value}" }.join(' AND ') + ' AND deleted_at IS NULL AND archived_at IS NULL' diff --git a/app/models/page_types/content_page.rb b/app/models/page_types/content_page.rb index 12e265a0..22c2ab64 100644 --- a/app/models/page_types/content_page.rb +++ b/app/models/page_types/content_page.rb @@ -1,7 +1,14 @@ class ContentPage < ApplicationRecord + include Rails.application.routes.url_helpers + belongs_to :user belongs_to :universe + attr_accessor :favorite + + include Authority::Abilities + self.authorizer_name = 'ContentPageAuthorizer' + def random_image_including_private(format: :small) ImageUpload.where(content_type: self.page_type, content_id: self.id).sample.try(:src, format) || "card-headers/#{self.page_type.downcase.pluralize}.jpg" end @@ -23,6 +30,14 @@ class ContentPage < ApplicationRecord end def view_path + send("#{self.page_type.downcase}_path", self.id) + end + def edit_path + send("edit_#{self.page_type.downcase}_path", self.id) + end + + def self.polymorphic_content_fields + [:id, :name, :favorite, :page_type, :user_id, :created_at, :updated_at, :deleted_at, :archived_at, :privacy] end end diff --git a/app/services/permission_service.rb b/app/services/permission_service.rb index 654e123c..98244b22 100644 --- a/app/services/permission_service.rb +++ b/app/services/permission_service.rb @@ -27,7 +27,11 @@ class PermissionService < Service def self.user_can_contribute_to_containing_universe?(user:, content:) return false if user.nil? return true if [AttributeCategory, AttributeField, Attribute].include?(content.class) #todo audit this - content.universe.present? && user.contributable_universes.pluck(:id).include?(content.universe.id) + + return true if user.contributable_universe_ids.include?(content.universe_id) + return true if user.universes.pluck(:id).include?(content.universe_id) + + return false end def self.content_has_no_containing_universe?(content:) diff --git a/app/views/content/list/_cards.html.erb b/app/views/content/list/_cards.html.erb index a08b5ece..f0e04816 100644 --- a/app/views/content/list/_cards.html.erb +++ b/app/views/content/list/_cards.html.erb @@ -4,14 +4,7 @@
    <%= render partial: 'content/display/favorite_control', locals: { content: content } %> - <% content_image = asset_path("card-headers/#{content_type.name.downcase.pluralize}.jpg") %> - <% if content.respond_to?(:image_uploads) %> - <% images = content.image_uploads %> - <% if images.any? %> - <% content_image = images.sample.src(:medium) %> - <% end %> - <% end %> -
    +
    @@ -35,13 +28,13 @@
    <% if current_user.can_update?(content) %> - <%= link_to edit_polymorphic_path(content), class: 'green-text right', target: content.is_a?(Document) ? '_new' : '_self' do %> + <%= link_to content.edit_path, class: 'green-text right', target: content.is_a?(Document) ? '_new' : '_self' do %> <%= content_type.icon %> Edit <% end %> <% end %> <% if current_user.can_read?(content) %> - <%= link_to polymorphic_path(content), class: 'blue-text text-lighten-1' do %> + <%= link_to content.view_path, class: 'blue-text text-lighten-1' do %> <%= content_type.icon %> View <% end %> From 0a42fe635c5e926571208547dee50a900cb596e7 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 9 Aug 2021 01:41:23 -0700 Subject: [PATCH 059/149] better safety around using @current_user_content --- app/views/content/components/_list_filter_bar.html.erb | 2 +- app/views/content/display/sidebar/_more.html.erb | 2 +- app/views/layouts/_document_sidenav.html.erb | 2 +- app/views/layouts/_sidenav.html.erb | 5 +++-- app/views/main/_dashboard_header_links.html.erb | 2 +- app/views/main/dashboard.html.erb | 4 ++-- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/views/content/components/_list_filter_bar.html.erb b/app/views/content/components/_list_filter_bar.html.erb index 88a01d90..ef00c91d 100644 --- a/app/views/content/components/_list_filter_bar.html.erb +++ b/app/views/content/components/_list_filter_bar.html.erb @@ -31,7 +31,7 @@
  • <% linkable_universes_with_this_kind_of_content = current_user.linkable_universes.select do |universe| - @current_user_content[content_type.name].any? { |content| content.universe_id == universe.id } + @current_user_content.fetch(content_type.name, []).any? { |content| content.universe_id == universe.id } end %> <% linkable_universes_with_this_kind_of_content.each do |universe| %> diff --git a/app/views/content/display/sidebar/_more.html.erb b/app/views/content/display/sidebar/_more.html.erb index 8dace646..0f82dd78 100644 --- a/app/views/content/display/sidebar/_more.html.erb +++ b/app/views/content/display/sidebar/_more.html.erb @@ -31,7 +31,7 @@ <%= link_to main_app.polymorphic_path(raw_model.class) do %> <%= raw_model.class.icon %> Your <%= raw_model.class.name.downcase.pluralize %> - <%= @current_user_content[raw_model.class.name].count %> + <%= @current_user_content.fetch(raw_model.class.name, []).count %> <% end %> <% else %> diff --git a/app/views/layouts/_document_sidenav.html.erb b/app/views/layouts/_document_sidenav.html.erb index bac5ef9e..5081e3c2 100644 --- a/app/views/layouts/_document_sidenav.html.erb +++ b/app/views/layouts/_document_sidenav.html.erb @@ -92,7 +92,7 @@
      - <% @current_user_content['Document'].each do |document| %> + <% @current_user_content.fetch('Document', []).each do |document| %>
    • <%= link_to edit_document_path(document), class: 'waves-effect tooltipped', data: { tooltip: "Last edited #{time_ago_in_words document.updated_at} ago", position: 'right' } do %> diff --git a/app/views/layouts/_sidenav.html.erb b/app/views/layouts/_sidenav.html.erb index 78a754e7..6d07ff4a 100644 --- a/app/views/layouts/_sidenav.html.erb +++ b/app/views/layouts/_sidenav.html.erb @@ -17,7 +17,8 @@
        - <% ((@current_user_content['Universe'] || []) + current_user.contributable_universes).sort_by(&:name).each do |universe| %> + <%# TODO: we should use a cache here %> + <% (@current_user_content.fetch('Universe', []) + current_user.contributable_universes).sort_by(&:name).each do |universe| %>
      • <%= link_to "?universe=#{universe.id}", class: 'waves-effect' do %> @@ -70,7 +71,7 @@ @universe_scope.send(pluralized_name).count else ( - @current_user_content[content_type] || [] + + @current_user_content.fetch(content_type, []) + current_user.send("contributable_#{pluralized_name}") + (content_type_klass == Universe ? [] : content_type_klass.where(universe_id: current_user.universes.pluck(:id))) ).uniq.count diff --git a/app/views/main/_dashboard_header_links.html.erb b/app/views/main/_dashboard_header_links.html.erb index 31de73c5..c6733984 100644 --- a/app/views/main/_dashboard_header_links.html.erb +++ b/app/views/main/_dashboard_header_links.html.erb @@ -3,7 +3,7 @@
        - <%= @current_user_content['Document'].count %> + <%= @current_user_content.fetch('Document', []).count %> <%= Document.icon %> Docs Documents diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index 9b7aaa63..b6b52bcc 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -125,7 +125,7 @@ <% end %> <% else %> <% - accessible_universes = ((@current_user_content['Universe'] || []) + current_user.contributable_universes) + accessible_universes = @current_user_content.fetch('Universe', []) + current_user.contributable_universes if accessible_universes.count > 1 %>
        @@ -196,7 +196,7 @@ <%= type %>
        You've created - <%= pluralize (@current_user_content[type] || []).count, type.downcase %> + <%= pluralize @current_user_content.fetch(type, []).count, type.downcase %> <% if @universe_scope %> in this universe <% end %> From 6f910cf62d97125b895a4bafcbca0c06b3b22bc4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Aug 2021 12:00:48 +0000 Subject: [PATCH 060/149] Bump rails_admin from 2.1.1 to 2.2.1 Bumps [rails_admin](https://github.com/sferik/rails_admin) from 2.1.1 to 2.2.1. - [Release notes](https://github.com/sferik/rails_admin/releases) - [Changelog](https://github.com/sferik/rails_admin/blob/master/CHANGELOG.md) - [Commits](https://github.com/sferik/rails_admin/compare/v2.1.1...v2.2.1) --- updated-dependencies: - dependency-name: rails_admin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 0a253993..30e315a4 100644 --- a/Gemfile +++ b/Gemfile @@ -89,7 +89,7 @@ gem 'redis' gem 'csv' # Admin -gem 'rails_admin', '~> 2.1' +gem 'rails_admin', '~> 2.2' # Tech debt & hacks gem 'binding_of_caller' # see has_changelog.rb diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..cda0eceb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1229,7 +1229,7 @@ GEM faye-websocket (0.11.1) eventmachine (>= 0.12.0) websocket-driver (>= 0.5.1) - ffi (1.15.0) + ffi (1.15.3) ffi-compiler (1.0.1) ffi (>= 1.0.0) rake @@ -1239,9 +1239,9 @@ GEM railties (>= 3.2, < 7) friendly_id (5.3.0) activerecord (>= 4.0.0) - globalid (0.4.2) - activesupport (>= 4.2.0) - haml (5.1.2) + globalid (0.5.2) + activesupport (>= 5.0) + haml (5.2.2) temple (>= 0.8.0) tilt html-pipeline (2.14.0) @@ -1307,7 +1307,7 @@ GEM listen (3.5.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.10.0) + loofah (2.11.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -1330,7 +1330,7 @@ GEM rake mini_magick (4.11.0) mini_mime (1.1.0) - mini_portile2 (2.5.3) + mini_portile2 (2.6.1) mini_racer (0.4.0) libv8-node (~> 15.14.0.0) minitest (5.14.4) @@ -1339,9 +1339,9 @@ GEM mustache (1.1.1) nested_form (0.3.2) newrelic_rpm (7.2.0) - nio4r (2.5.7) - nokogiri (1.11.7) - mini_portile2 (~> 2.5.0) + nio4r (2.5.8) + nokogiri (1.12.2) + mini_portile2 (~> 2.6.1) racc (~> 1.4) nokogumbo (2.0.2) nokogiri (~> 1.8, >= 1.8.4) @@ -1414,7 +1414,7 @@ GEM rails (>= 3.2) rails-ujs (0.1.0) railties (>= 3.1) - rails_admin (2.1.1) + rails_admin (2.2.1) activemodel-serializers-xml (>= 1.0) builder (~> 3.1) haml (>= 4.0, < 6) @@ -1590,7 +1590,7 @@ DEPENDENCIES rails rails-jquery-autocomplete rails-ujs - rails_admin (~> 2.1) + rails_admin (~> 2.2) react-rails redcarpet redis From 2fb72180d210ad305484beb19b391afaea60da06 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 9 Aug 2021 12:10:18 -0700 Subject: [PATCH 061/149] fix default image url --- app/models/page_types/content_page.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/page_types/content_page.rb b/app/models/page_types/content_page.rb index 22c2ab64..c476d831 100644 --- a/app/models/page_types/content_page.rb +++ b/app/models/page_types/content_page.rb @@ -10,7 +10,7 @@ class ContentPage < ApplicationRecord self.authorizer_name = 'ContentPageAuthorizer' def random_image_including_private(format: :small) - ImageUpload.where(content_type: self.page_type, content_id: self.id).sample.try(:src, format) || "card-headers/#{self.page_type.downcase.pluralize}.jpg" + ImageUpload.where(content_type: self.page_type, content_id: self.id).sample.try(:src, format) || "/assets/card-headers/#{self.page_type.downcase.pluralize}.jpg" end def icon From e4e54854a9fc3c447c2418dd6f15fcff3b37b9c5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 9 Aug 2021 12:47:21 -0700 Subject: [PATCH 062/149] re-enable universe filtering on timelines#index --- app/controllers/timelines_controller.rb | 2 ++ app/models/concerns/has_content.rb | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/timelines_controller.rb b/app/controllers/timelines_controller.rb index 2bd4f351..3e243cce 100644 --- a/app/controllers/timelines_controller.rb +++ b/app/controllers/timelines_controller.rb @@ -7,6 +7,8 @@ class TimelinesController < ApplicationController # GET /timelines def index + cache_linkable_content_for_each_content_type + @timelines = current_user.timelines @page_title = "My timelines" diff --git a/app/models/concerns/has_content.rb b/app/models/concerns/has_content.rb index 7951d542..c12f6f4c 100644 --- a/app/models/concerns/has_content.rb +++ b/app/models/concerns/has_content.rb @@ -16,6 +16,7 @@ module HasContent has_many :attribute_categories has_many :attribute_values, class_name: 'Attribute', dependent: :destroy + # Alternative approach to #content for benchmarking in prod def content_with_multiple_queries( content_types: Rails.application.config.content_type_names[:all], page_scoping: { user_id: self.id }, @@ -52,7 +53,7 @@ module HasContent page_scoping: { user_id: self.id }, universe_id: nil ) - return content_with_multiple_queries(content_types: content_types, page_scoping: page_scoping, universe_id: universe_id) + # return content_with_multiple_queries(content_types: content_types, page_scoping: page_scoping, universe_id: universe_id) return {} if content_types.empty? # TODO: we should return early if we already have @content_by_page_type!!! From 79267129d7d015f529f48b9f6f7ddc3e4b415c0a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 9 Aug 2021 13:59:21 -0700 Subject: [PATCH 063/149] use contentpages in serendipitous --- app/controllers/content_controller.rb | 2 -- app/services/serendipitous_service.rb | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index d74d44df..ac8c5263 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -21,8 +21,6 @@ class ContentController < ApplicationController before_action :set_sidenav_expansion, except: [:api_sort] def index - cache_linkable_content_for_each_content_type - @content_type_class = content_type_from_controller(self.class) pluralized_content_name = @content_type_class.name.downcase.pluralize diff --git a/app/services/serendipitous_service.rb b/app/services/serendipitous_service.rb index 0f81cb3d..eb77ea37 100644 --- a/app/services/serendipitous_service.rb +++ b/app/services/serendipitous_service.rb @@ -4,7 +4,7 @@ class SerendipitousService < Service categories_for_this_type = AttributeCategory.where( user: content.user, - entity_type: content.class.name.downcase, + entity_type: content.page_type.downcase, hidden: [nil, false] ) @@ -25,7 +25,7 @@ class SerendipitousService < Service #raise fields_for_these_categories.pluck(:label).inspect attribute_fields_with_values = Attribute.where( - entity_type: content.class.name, + entity_type: content.page_type, entity_id: content.id, attribute_field_id: fields_for_these_categories.pluck(:id) ).where.not( From e71e3c3062e8455ece51962cb92fd023bfed58c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Aug 2021 12:01:25 +0000 Subject: [PATCH 064/149] Bump stripe from 5.37.0 to 5.38.0 Bumps [stripe](https://github.com/stripe/stripe-ruby) from 5.37.0 to 5.38.0. - [Release notes](https://github.com/stripe/stripe-ruby/releases) - [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md) - [Commits](https://github.com/stripe/stripe-ruby/compare/v5.37.0...v5.38.0) --- updated-dependencies: - dependency-name: stripe dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..8ae94b95 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1497,7 +1497,7 @@ GEM sqlite3 (1.4.2) stackprof (0.2.17) statsd-ruby (1.5.0) - stripe (5.37.0) + stripe (5.38.0) stripe_event (2.3.1) activesupport (>= 3.1) stripe (>= 2.8, < 6) From ac4c3dbd61935c1617698ab0d6f75c13c5c15a51 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 11 Aug 2021 16:53:48 -0700 Subject: [PATCH 065/149] linkables cache safety --- app/controllers/application_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cc98399c..4b053e95 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -184,6 +184,11 @@ class ApplicationController < ActionController::Base end end + # We can't properly display or @-mention content without a name set, so we explicitly + # reject it here. However, this is a bit of a code-smell: why is there content without + # a name set? + @linkables_raw[page_type].reject! { |page| page.name.nil? } + # Finally, we want to sort our linkables cache once so we don't have to sort it again @linkables_raw[page_type].sort_by! { |page| page.name.downcase }.compact! From ed71129c487477f2fa496cffda202c081c29c0c9 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 11 Aug 2021 17:15:32 -0700 Subject: [PATCH 066/149] get serendipitous questions working on content#index for ContentPage data --- app/controllers/content_controller.rb | 5 ++ app/services/field_type_service.rb | 9 +++ .../serendipitous/_content_question.html.erb | 23 ++++--- .../_text_input_for_content_page.html.erb | 62 +++++++++++++++++++ app/views/content/index.html.erb | 2 +- 5 files changed, 90 insertions(+), 11 deletions(-) create mode 100644 app/views/content/form/_text_input_for_content_page.html.erb diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index ac8c5263..f299c17c 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -510,6 +510,11 @@ class ContentController < ApplicationController .where.not(id: valid_reference_ids) .destroy_all end + + respond_to do |format| + format.html { redirect_back(fallback_location: root_path, notice: "#{@attribute_field.label} updated!") } + format.json { render json: attribute_value, status: :success } + end end def tags_field_update diff --git a/app/services/field_type_service.rb b/app/services/field_type_service.rb index 19f7b197..0d5798e0 100644 --- a/app/services/field_type_service.rb +++ b/app/services/field_type_service.rb @@ -15,4 +15,13 @@ class FieldTypeService < Service raise "Unexpected/unhandled field type: #{field[:type]}" end end + + def self.form_path_from_attribute_field(field) + field_data = { + type: field.field_type, + internal_id: field.id + } + + form_path(field_data) + end end diff --git a/app/views/cards/serendipitous/_content_question.html.erb b/app/views/cards/serendipitous/_content_question.html.erb index 182875c0..deea2560 100644 --- a/app/views/cards/serendipitous/_content_question.html.erb +++ b/app/views/cards/serendipitous/_content_question.html.erb @@ -6,22 +6,25 @@ <% if defined?(field) && field.present? %>
        • -
          - help +
          + help <%= t( - "serendipitous_questions.attributes.#{content.class.name.downcase}.#{field.label.downcase}", - name: content.name_field_value, - default: "What is #{content.name_field_value}'s #{field.label.downcase}?" + "serendipitous_questions.attributes.#{content.page_type.downcase}.#{field.label.downcase}", + name: content.name, + default: "What is #{content.name}'s #{field.label.downcase}?" ) %>
          - <%= form_for content do |f| %> + <%= form_for content, url: FieldTypeService.form_path_from_attribute_field(field), method: :patch do |f| %> <%= hidden_field(:override, :redirect_path, value: redirect_path) if defined?(redirect_path) %> + <%= hidden_field_tag "entity[entity_id]", content.id %> + <%= hidden_field_tag "entity[entity_type]", content.page_type %> + <%= - render 'content/form/text_input', + render 'content/form/text_input_for_content_page', f: f, content: content, field: field @@ -32,14 +35,14 @@ <% end %> <% if include_quick_reference %> - <%= link_to content, class: 'entity-trigger sidenav-trigger orange white-text btn tooltipped', data: { target: "quick-reference-#{@content.class.name}-#{@content.id}", tooltip: "View this #{@content.class.name.downcase} without leaving this page" } do %> + <%= link_to content.view_path, class: 'entity-trigger sidenav-trigger orange white-text btn tooltipped', data: { target: "quick-reference-#{content.name}-#{content.id}", tooltip: "View this #{content.page_type.downcase} without leaving this page" } do %> vertical_split Quick-reference <% end %> <% end %> <% if !defined?(show_view_button) || !!show_view_button %> - <%= link_to content, class: "btn #{content.class.color} white-text tooltipped", target: '_new', data: { tooltip: "View this #{@content.class.name.downcase} in a new tab" } do %> - <%= content.class.icon %> + <%= link_to content.view_path, class: "btn #{content.color} white-text tooltipped", target: '_new', data: { tooltip: "View this #{content.name.downcase} in a new tab" } do %> + <%= content.icon %> View <% end %> <% end %> diff --git a/app/views/content/form/_text_input_for_content_page.html.erb b/app/views/content/form/_text_input_for_content_page.html.erb new file mode 100644 index 00000000..74584dd9 --- /dev/null +++ b/app/views/content/form/_text_input_for_content_page.html.erb @@ -0,0 +1,62 @@ +<% + content_name = content.page_type.downcase + + field_id = "#{content_name}_#{field.name}" + value = field.attribute_values.find_by( + user: content.user, + entity_type: content.page_type, + entity_id: content.id + ).try(:value) + + should_autocomplete = defined?(autocomplete) && !!autocomplete + should_autosave = defined?(autosave) && !!autosave +%> + +
          + <% unless defined?(show_label) && !show_label %> + <%= f.label field.id do %> + <%= field.label.present? ? field.label : ' ' %> + <% if defined?(autocomplete) && autocomplete %> + + offline_bolt + + <% end %> + <% end %> + <% end %> + <% + placeholder = I18n.translate "attributes.#{content_name}.#{field.name}", + scope: :serendipitous_questions, + name: content.name || "this #{content_name}", + default: 'Write as little or as much as you want!' + %> + + <%= hidden_field_tag "field[name]", field[:id] %> + <%= + text_area_tag "field[value]", + value, + class: "js-can-mention-pages materialize-textarea" \ + + "#{' autocomplete js-autocomplete-' + field[:id].to_s if should_autocomplete}" \ + + "#{' autosave-closest-form-on-change' if should_autosave}", + placeholder: placeholder + %> +
          + +<% if defined?(autocomplete) && autocomplete %> + <%= content_for :javascript do %> + $(function() { + // This setTimeout is an unfortunate hack to ensure this runs after initializing materialize + setTimeout(function() { + console.log("Initializing autocomplete for #<%= "#{content_name}_#{field.label}" %>"); + + $('.js-autocomplete-<%= field.id.to_s %>').autocomplete({ + limit: 5, + data: { + <% autocomplete.each do |autocomplete_option| %> + "<%= autocomplete_option %>": null, + <% end %> + } + }); + }, 1000); + }); + <% end %> +<% end %> diff --git a/app/views/content/index.html.erb b/app/views/content/index.html.erb index 8a58a7d2..c76b2bb9 100644 --- a/app/views/content/index.html.erb +++ b/app/views/content/index.html.erb @@ -13,7 +13,7 @@
          <%= render partial: 'cards/serendipitous/content_question', locals: { content: @questioned_content, - field: @attribute_field_to_question + field: @attribute_field_to_question } %>
          <% end %> From 09f248d88f1c86d01f7e5d0de8857942bc56e950 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 11 Aug 2021 19:36:40 -0700 Subject: [PATCH 067/149] save a bunch of queries by using cached ContentPages on dashboard --- app/controllers/content_controller.rb | 1 + app/controllers/main_controller.rb | 22 +------------------ .../_text_input_for_content_page.html.erb | 2 +- app/views/main/dashboard.html.erb | 18 ++++++++------- 4 files changed, 13 insertions(+), 30 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index f299c17c..943b86b5 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -80,6 +80,7 @@ class ContentController < ApplicationController @questioned_content = @content.sample @attribute_field_to_question = SerendipitousService.question_for(@questioned_content) + # Uh, do we ever actually make JSON requests to logged-in user pages? respond_to do |format| format.html { render 'content/index' } format.json { render json: @content } diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 255f1492..04ddc1c9 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -74,26 +74,6 @@ class MainController < ApplicationController private def set_random_content - @activated_content_types.shuffle.each do |content_type| - if content_type == Universe.name - if @universe_scope.present? - @content = content_type.constantize.where(user: current_user, id: @universe_scope.id).includes(:user) - else - @content = content_type.constantize.where(user: current_user).includes(:user) - end - else - if @universe_scope.present? - # when we want to enable prompts for contributing universes we can remove the user: - # selector here, but we will need to verify the user has permission to see the universe - # when we do that, or else prompts could open leak - @content = content_type.constantize.where(user: current_user, universe: @universe_scope).includes(:user, :universe) - else - @content = content_type.constantize.where(user: current_user).includes(:user, :universe) - end - end - - @content = @content.sample - return if @content.present? - end + @content = @current_user_content.except(*%w(Timeline Document)).values.flatten.sample end end diff --git a/app/views/content/form/_text_input_for_content_page.html.erb b/app/views/content/form/_text_input_for_content_page.html.erb index 74584dd9..00837ccb 100644 --- a/app/views/content/form/_text_input_for_content_page.html.erb +++ b/app/views/content/form/_text_input_for_content_page.html.erb @@ -24,7 +24,7 @@ <% end %> <% end %> <% - placeholder = I18n.translate "attributes.#{content_name}.#{field.name}", + placeholder = I18n.translate "attributes.#{content_name}.#{field.label.downcase.gsub(/\s/, '_')}", scope: :serendipitous_questions, name: content.name || "this #{content_name}", default: 'Write as little or as much as you want!' diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index b6b52bcc..692d507d 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -72,14 +72,16 @@ your worlds <% end %>
          - <% if @content %> - <%= render partial: 'cards/serendipitous/content_question', locals: { - content: @content, - field: @attribute_field_to_question, - expand_by_default: true, - include_quick_reference: false - } %> - <% end %> + <%= + if @content + render partial: 'cards/serendipitous/content_question', locals: { + content: @content, + field: @attribute_field_to_question, + expand_by_default: true, + include_quick_reference: false + } + end + %> <%= link_to prompts_path do %>
          From 56f2b410b5c49824df8f5da49a22fa80b299aded Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 11 Aug 2021 21:47:33 -0700 Subject: [PATCH 068/149] use ContentPage piping on prompts page --- app/controllers/main_controller.rb | 9 +++--- .../serendipitous/_content_question.html.erb | 2 +- app/views/main/prompts.html.erb | 7 +++-- app/views/prompts/_smart_sidebar.html.erb | 29 ++++++++++++------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 04ddc1c9..970768a1 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -25,8 +25,7 @@ class MainController < ApplicationController def dashboard @page_title = "My notebook" - set_random_content # for questions - @attribute_field_to_question = SerendipitousService.question_for(@content) + set_questionable_content # for questions end def infostack @@ -40,8 +39,7 @@ class MainController < ApplicationController @navbar_color = '#FF9800' @page_title = "Writing prompts" - set_random_content # for question - @attribute_field_to_question = SerendipitousService.question_for(@content) + set_questionable_content # for question end # deprecated path just kept around for bookmarks for a while @@ -73,7 +71,8 @@ class MainController < ApplicationController private - def set_random_content + def set_questionable_content @content = @current_user_content.except(*%w(Timeline Document)).values.flatten.sample + @attribute_field_to_question = SerendipitousService.question_for(@content) end end diff --git a/app/views/cards/serendipitous/_content_question.html.erb b/app/views/cards/serendipitous/_content_question.html.erb index deea2560..b02d7103 100644 --- a/app/views/cards/serendipitous/_content_question.html.erb +++ b/app/views/cards/serendipitous/_content_question.html.erb @@ -35,7 +35,7 @@ <% end %> <% if include_quick_reference %> - <%= link_to content.view_path, class: 'entity-trigger sidenav-trigger orange white-text btn tooltipped', data: { target: "quick-reference-#{content.name}-#{content.id}", tooltip: "View this #{content.page_type.downcase} without leaving this page" } do %> + <%= link_to content.view_path, class: 'entity-trigger sidenav-trigger orange white-text btn tooltipped', data: { target: "quick-reference-#{content.page_type}-#{content.id}", tooltip: "View this #{content.page_type.downcase} without leaving this page" } do %> vertical_split Quick-reference <% end %> diff --git a/app/views/main/prompts.html.erb b/app/views/main/prompts.html.erb index d0d4585b..ac6a01cf 100644 --- a/app/views/main/prompts.html.erb +++ b/app/views/main/prompts.html.erb @@ -12,7 +12,8 @@ redirect_path: prompts_path, show_empty_prompt: true, expand_by_default: true, - show_view_button: false + show_view_button: false, + include_quick_reference: false } %>

          @@ -23,8 +24,8 @@ <% if @attribute_field_to_question.present? %>

          - <%= link_to @content, class: 'entity-trigger sidenav-trigger', data: { target: "quick-reference-#{@content.class.name}-#{@content.id}"} do %> -
          + <%= link_to @content.view_path, class: 'entity-trigger sidenav-trigger', data: { target: "quick-reference-#{@content.page_type}-#{@content.id}"} do %> +
          vertical_split Quick-reference <%= @content.name %> diff --git a/app/views/prompts/_smart_sidebar.html.erb b/app/views/prompts/_smart_sidebar.html.erb index e72ea6d7..0edd19fb 100644 --- a/app/views/prompts/_smart_sidebar.html.erb +++ b/app/views/prompts/_smart_sidebar.html.erb @@ -1,16 +1,25 @@ -<%# todo extract "sidebar" and call it with @content, then also do the same in documents/components/smart_sidebar %> -<% serialized_entity = ContentSerializer.new(content) %> +<%# + This sidebar partial uses instantiated ContentPage models instead of the persisted content models (Character, Location, etc) -
            + TODO: merge this with documents/components/smart_sidebar +%> + +<%# todo extract "sidebar" and call it with @content, then also do the same in documents/components/smart_sidebar %> +<% + raw_model = content.page_type.constantize.find_by(id: content.id, user: current_user) + serialized_entity = ContentSerializer.new(raw_model) +%> + +
            • - <%= image_tag "card-headers/#{content.class.name.downcase.pluralize}.jpg", width: '100%' %> + <%= image_tag "card-headers/#{content.page_type.downcase.pluralize}.jpg", width: '100%' %>

              - - <%= content.class.icon %> + + <%= content.icon %> <%= content.name %>

              @@ -83,15 +92,15 @@
            • Actions
            • - <%= link_to polymorphic_path(content), class: "blue-text", target: '_new' do %> - <%= content.class.icon %> + <%= link_to content.view_path, class: "blue-text", target: '_new' do %> + <%= content.icon %> exit_to_app View <%= content.name %> <% end %>
            • - <%= link_to edit_polymorphic_path(content), class: "green-text" do %> - <%= content.class.icon %> + <%= link_to content.edit_path, class: "green-text" do %> + <%= content.icon %> exit_to_app Edit <%= content.name %> <% end %> From 22d199aeadf1e5a8d6bde546b3ab73fe7a774466 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 11 Aug 2021 21:51:14 -0700 Subject: [PATCH 069/149] clean up code rework --- app/controllers/content_controller.rb | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 943b86b5..68808543 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -35,30 +35,6 @@ class ContentController < ApplicationController @show_scope_notice = @universe_scope.present? && content_type_class != Universe - # if @universe_scope.present? && @content_type_class != Universe - # # Linkables cache is already scoped per-universe - - # @content = @current_user_content.fetch(@content_type_class.name, []) - # .select { |page| page.universe_id == @universe_scope.id } - - # @content = @universe_scope.send(pluralized_content_name) - # .includes(:page_tags, :image_uploads) - # .unarchived - - # @show_scope_notice = true - # else - # @content = ( - # current_user.send(pluralized_content_name).unarchived.includes(:page_tags, :image_uploads) + - # current_user.send("contributable_#{pluralized_content_name}").unarchived.includes(:page_tags, :image_uploads) - # ) - - # if @content_type_class != Universe - # my_universe_ids = current_user.universes.pluck(:id) - # @content.concat(@content_type_class.where(universe_id: my_universe_ids).unarchived) - # end - # end - # @content = @content.to_a.flatten.uniq - # Filters @page_tags = PageTag.where( page_type: @content_type_class.name, From 406105ecf02d57cef247360743a478c6fd38d897 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 13 Aug 2021 10:32:56 -0700 Subject: [PATCH 070/149] move references into a job (needs tested) --- app/controllers/content_controller.rb | 30 ++-------------- app/jobs/document_entity_analysis_job.rb | 2 +- .../update_text_attribute_references_job.rb | 36 +++++++++++++++++++ 3 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 app/jobs/update_text_attribute_references_job.rb diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 68808543..78f7942c 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -44,13 +44,12 @@ class ContentController < ApplicationController @filtered_page_tags = @page_tags.where(slug: params[:tag]) @content.select! { |content| @filtered_page_tags.pluck(:page_id).include?(content.id) } end + @page_tags = @page_tags.uniq(&:tag) if params.key?(:favorite_only) @content.select!(&:favorite?) end - @page_tags = @page_tags.uniq(&:tag) - @content = @content.sort_by {|x| [x.favorite? ? 0 : 1, x.name] } @questioned_content = @content.sample @@ -414,6 +413,7 @@ class ContentController < ApplicationController set_entity referencing_page = @entity + # TODO: move this into a link mention update job valid_reference_ids = [] referenced_page_codes = JSON.parse(attribute_value.value) referenced_page_codes.each do |page_code| @@ -462,31 +462,7 @@ class ContentController < ApplicationController attribute_value.value = text attribute_value.save! - # Create PageReferences for mentioned pages - tokens = ContentFormatterService.tokens_to_replace(text) - if tokens.any? - set_entity - - valid_reference_ids = [] - tokens.each do |token| - reference = @entity.outgoing_page_references.find_or_initialize_by( - referenced_page_type: token[:content_type], - referenced_page_id: token[:content_id], - attribute_field_id: @attribute_field.id, - reference_type: 'mentioned' - ) - reference.cached_relation_title = @attribute_field.label - reference.save! - - valid_reference_ids << reference.reload.id - end - - # Delete all other references still attached to this field, but not present in this request - @entity.outgoing_page_references - .where(attribute_field_id: @attribute_field.id) - .where.not(id: valid_reference_ids) - .destroy_all - end + UpdateTextAttributeReferencesJob.perform_later(attribute_value.id) respond_to do |format| format.html { redirect_back(fallback_location: root_path, notice: "#{@attribute_field.label} updated!") } diff --git a/app/jobs/document_entity_analysis_job.rb b/app/jobs/document_entity_analysis_job.rb index 35ffb337..f91f1c1d 100644 --- a/app/jobs/document_entity_analysis_job.rb +++ b/app/jobs/document_entity_analysis_job.rb @@ -4,7 +4,7 @@ class DocumentEntityAnalysisJob < ApplicationJob def perform(*args) document_entity_id = args.shift - entity = DocumentEntity.find(document_entity_id) + entity = DocumentEntity.find_by(id: document_entity_id) return unless entity.present? Documents::Analysis::ThirdParty::IbmWatsonService.analyze_entity(document_entity_id) diff --git a/app/jobs/update_text_attribute_references_job.rb b/app/jobs/update_text_attribute_references_job.rb new file mode 100644 index 00000000..598d7eaa --- /dev/null +++ b/app/jobs/update_text_attribute_references_job.rb @@ -0,0 +1,36 @@ +class UpdateTextAttributeReferencesJob < ApplicationJob + queue_as :mentions + + def perform(*args) + attribute_id = args.shift + + attribute = Attribute.find_by(id: attribute_id) + return unless attribute.present? + + # Create PageReferences for mentioned pages + tokens = ContentFormatterService.tokens_to_replace(attribute.value) + if tokens.any? + entity = attribute.entity + + valid_reference_ids = [] + tokens.each do |token| + reference = entity.outgoing_page_references.find_or_initialize_by( + referenced_page_type: token[:content_type], + referenced_page_id: token[:content_id], + attribute_field_id: attribute.attribute_field_id, + reference_type: 'mentioned' + ) + reference.cached_relation_title = AttributeField.find_by(id: attribute.attribute_field_id).try(:label) + reference.save! + + valid_reference_ids << reference.reload.id + end + + # Delete all other references still attached to this field, but not present in this request + entity.outgoing_page_references + .where(attribute_field_id: attribute.attribute_field_id) + .where.not(id: valid_reference_ids) + .destroy_all + end + end +end From 3a84ac68fc29445902d5dd483dffd5d0014691e6 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 13 Aug 2021 10:33:26 -0700 Subject: [PATCH 071/149] force heroku rebuild --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 5a337e3d..63391b40 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,4 +1,4 @@ -= Notebook.ai += Notebook.ai {}[https://codeclimate.com/github/indentlabs/notebook] {}[https://codeclimate.com/github/indentlabs/notebook/coverage] {Inline docs}[http://inch-ci.org/github/indentlabs/notebook] From 54e16a1ca8b763f9381aefc4b13c4d852e652e2d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Aug 2021 12:00:55 +0000 Subject: [PATCH 072/149] Bump bullet from 6.1.4 to 6.1.5 Bumps [bullet](https://github.com/flyerhzm/bullet) from 6.1.4 to 6.1.5. - [Release notes](https://github.com/flyerhzm/bullet/releases) - [Changelog](https://github.com/flyerhzm/bullet/blob/master/CHANGELOG.md) - [Commits](https://github.com/flyerhzm/bullet/compare/6.1.4...6.1.5) --- updated-dependencies: - dependency-name: bullet dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..06922554 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1172,7 +1172,7 @@ GEM binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) builder (3.2.4) - bullet (6.1.4) + bullet (6.1.5) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) bundler-audit (0.8.0) @@ -1519,7 +1519,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.7) - uniform_notifier (1.14.1) + uniform_notifier (1.14.2) warden (1.2.9) rack (>= 2.0.9) web-console (4.1.0) From b719cd4ac2189cac921890678902b5df7da227a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Aug 2021 12:00:55 +0000 Subject: [PATCH 073/149] Bump listen from 3.5.1 to 3.7.0 Bumps [listen](https://github.com/guard/listen) from 3.5.1 to 3.7.0. - [Release notes](https://github.com/guard/listen/releases) - [Commits](https://github.com/guard/listen/compare/v3.5.1...v3.7.0) --- updated-dependencies: - dependency-name: listen dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..951a1d89 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1229,7 +1229,7 @@ GEM faye-websocket (0.11.1) eventmachine (>= 0.12.0) websocket-driver (>= 0.5.1) - ffi (1.15.0) + ffi (1.15.3) ffi-compiler (1.0.1) ffi (>= 1.0.0) rake @@ -1304,7 +1304,7 @@ GEM kramdown (~> 2.0) language_filter (0.3.01) libv8-node (15.14.0.1) - listen (3.5.1) + listen (3.7.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) loofah (2.10.0) From 5c1de3391581699926396603e56f9e8f99a802cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Sep 2021 00:03:01 +0000 Subject: [PATCH 074/149] Bump tar from 6.1.0 to 6.1.11 Bumps [tar](https://github.com/npm/node-tar) from 6.1.0 to 6.1.11. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/node-tar/compare/v6.1.0...v6.1.11) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 90597e95..5975e7c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6584,9 +6584,9 @@ tapable@^1.0.0, tapable@^1.1.3: integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== tar@^6.0.2: - version "6.1.0" - resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.0.tgz#d1724e9bcc04b977b18d5c573b333a2207229a83" - integrity sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA== + version "6.1.11" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" + integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== dependencies: chownr "^2.0.0" fs-minipass "^2.0.0" From e359474882c86b3418302e68d39aa74841e7ab43 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 4 Sep 2021 16:48:26 -0700 Subject: [PATCH 075/149] update installation instructions, remove docker mention, closes #961 --- README.rdoc | 49 +------------------------------------------------ 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/README.rdoc b/README.rdoc index 63391b40..68801893 100644 --- a/README.rdoc +++ b/README.rdoc @@ -34,54 +34,7 @@ TL;DR Milestones are independent of each other -- work on whatever you want to s == Installing the notebook development stack locally -Install ruby 2.6.6 (using `rbenv`, `rvm`, any other Ruby version manager, or just plain ol' ruby) - - rbenv install 2.6.6 - -Install necessary libraries - - sudo apt install imagemagick libmagickwand-dev - sudo apt install libpq-dev - -Clone the code - - git clone git@github.com:indentlabs/notebook.git - -Install gems - - bundle install - -Create database - - rake db:create - -Run initial database migrations - - rake db:migrate - rake billing_plans:initialize_defaults - rake data_migrations:create_default_billing_plans - rake db:seed - -Finally, run the server with - - bundle exec rails server - -You should now see a copy of the site running locally at http://localhost:3000/! - -You can also run background workers with sidekiq (and can run specific queues with the `-q ` flag): - - bundle exec sidekiq -C config/sidekiq.yml - -== Running the notebook stack locally with Docker - -Please note that the Docker installation is managed by the community, so it may not always be up to date. I recommend installing the stack manually. - -- install {Docker}[https://www.docker.com/products/overview] -- install {Docker Compose}[https://docs.docker.com/compose/install] -- clone this git repo -- cd into the root of this repo, and then run - docker-compose up -- You should now see a copy of the site running locally at http://localhost:3000/ +Please see the [Installation Guide](https://github.com/indentlabs/notebook/wiki/Setup-Instructions) in the wiki for setup instructions. == Testing From d7501b42d48863dfbc315b851e9fe8eb26ba39a5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 4 Sep 2021 17:01:22 -0700 Subject: [PATCH 076/149] oops, this is rdoc, not markdown --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 68801893..009d2de7 100644 --- a/README.rdoc +++ b/README.rdoc @@ -34,7 +34,7 @@ TL;DR Milestones are independent of each other -- work on whatever you want to s == Installing the notebook development stack locally -Please see the [Installation Guide](https://github.com/indentlabs/notebook/wiki/Setup-Instructions) in the wiki for setup instructions. +Please see the {installation Guide}[https://github.com/indentlabs/notebook/wiki/Setup-Instructions] in the wiki for setup instructions. == Testing From 8ab29a6c83f4f9f4bda2fb1d52880f8e21d94552 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 14 Sep 2021 19:37:27 -0700 Subject: [PATCH 077/149] Revert "Bump rails from 6.0.3.2 to 6.0.3.4" This reverts commit 0f47cf8e998446dfba4acf8d0daa7d2ed9500e47. --- Gemfile.lock | 96 ++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..1aaf9a8d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,38 +41,38 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.0.3.4) - actionpack (= 6.0.3.4) + actioncable (6.0.3.2) + actionpack (= 6.0.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3.4) - actionpack (= 6.0.3.4) - activejob (= 6.0.3.4) - activerecord (= 6.0.3.4) - activestorage (= 6.0.3.4) - activesupport (= 6.0.3.4) + actionmailbox (6.0.3.2) + actionpack (= 6.0.3.2) + activejob (= 6.0.3.2) + activerecord (= 6.0.3.2) + activestorage (= 6.0.3.2) + activesupport (= 6.0.3.2) mail (>= 2.7.1) - actionmailer (6.0.3.4) - actionpack (= 6.0.3.4) - actionview (= 6.0.3.4) - activejob (= 6.0.3.4) + actionmailer (6.0.3.2) + actionpack (= 6.0.3.2) + actionview (= 6.0.3.2) + activejob (= 6.0.3.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3.4) - actionview (= 6.0.3.4) - activesupport (= 6.0.3.4) + actionpack (6.0.3.2) + actionview (= 6.0.3.2) + activesupport (= 6.0.3.2) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3.4) - actionpack (= 6.0.3.4) - activerecord (= 6.0.3.4) - activestorage (= 6.0.3.4) - activesupport (= 6.0.3.4) + actiontext (6.0.3.2) + actionpack (= 6.0.3.2) + activerecord (= 6.0.3.2) + activestorage (= 6.0.3.2) + activesupport (= 6.0.3.2) nokogiri (>= 1.8.5) - actionview (6.0.3.4) - activesupport (= 6.0.3.4) + actionview (6.0.3.2) + activesupport (= 6.0.3.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -81,24 +81,24 @@ GEM activerecord (>= 4.0) active_storage_validations (0.9.5) rails (>= 5.2.0) - activejob (6.0.3.4) - activesupport (= 6.0.3.4) + activejob (6.0.3.2) + activesupport (= 6.0.3.2) globalid (>= 0.3.6) - activemodel (6.0.3.4) - activesupport (= 6.0.3.4) + activemodel (6.0.3.2) + activesupport (= 6.0.3.2) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.0.3.4) - activemodel (= 6.0.3.4) - activesupport (= 6.0.3.4) - activestorage (6.0.3.4) - actionpack (= 6.0.3.4) - activejob (= 6.0.3.4) - activerecord (= 6.0.3.4) + activerecord (6.0.3.2) + activemodel (= 6.0.3.2) + activesupport (= 6.0.3.2) + activestorage (6.0.3.2) + actionpack (= 6.0.3.2) + activejob (= 6.0.3.2) + activerecord (= 6.0.3.2) marcel (~> 0.3.1) - activesupport (6.0.3.4) + activesupport (6.0.3.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -1390,20 +1390,20 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.0.3.4) - actioncable (= 6.0.3.4) - actionmailbox (= 6.0.3.4) - actionmailer (= 6.0.3.4) - actionpack (= 6.0.3.4) - actiontext (= 6.0.3.4) - actionview (= 6.0.3.4) - activejob (= 6.0.3.4) - activemodel (= 6.0.3.4) - activerecord (= 6.0.3.4) - activestorage (= 6.0.3.4) - activesupport (= 6.0.3.4) + rails (6.0.3.2) + actioncable (= 6.0.3.2) + actionmailbox (= 6.0.3.2) + actionmailer (= 6.0.3.2) + actionpack (= 6.0.3.2) + actiontext (= 6.0.3.2) + actionview (= 6.0.3.2) + activejob (= 6.0.3.2) + activemodel (= 6.0.3.2) + activerecord (= 6.0.3.2) + activestorage (= 6.0.3.2) + activesupport (= 6.0.3.2) bundler (>= 1.3.0) - railties (= 6.0.3.4) + railties (= 6.0.3.2) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -1490,7 +1490,7 @@ GEM babel-source (>= 5.8.11) babel-transpiler sprockets (>= 3.0.0) - sprockets-rails (3.2.2) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) From 10c3d1b60ab7d38621f3971d53abf62bd2cba47a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 14 Sep 2021 20:03:26 -0700 Subject: [PATCH 078/149] add this migration which... might help? --- ..._service_name_from_active_storage_blobs.rb | 19 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb diff --git a/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb b/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb new file mode 100644 index 00000000..935d09bc --- /dev/null +++ b/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb @@ -0,0 +1,19 @@ +class RemoveServiceNameFromActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + if column_exists?(:active_storage_blobs, :service_name) + remove_column :active_storage_blobs, :service_name + end + end + + def down + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d1fb2b45..91d7d384 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_07_05_005416) do +ActiveRecord::Schema.define(version: 2021_09_15_030031) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false From 7ea89ecac63fcf94dacf90d58a38a4ee9659df46 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 14 Sep 2021 20:12:12 -0700 Subject: [PATCH 079/149] actually, lets just tackle it this way --- ..._remove_service_name_from_active_storage_blobs.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb b/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb index 935d09bc..53f6dbdf 100644 --- a/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb +++ b/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb @@ -1,19 +1,13 @@ class RemoveServiceNameFromActiveStorageBlobs < ActiveRecord::Migration[6.0] def up if column_exists?(:active_storage_blobs, :service_name) - remove_column :active_storage_blobs, :service_name + change_column_default :active_storage_blobs, :service_name, "amazon" end end def down - unless column_exists?(:active_storage_blobs, :service_name) - add_column :active_storage_blobs, :service_name, :string - - if configured_service = ActiveStorage::Blob.service.name - ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) - end - - change_column :active_storage_blobs, :service_name, :string, null: false + if column_exists?(:active_storage_blobs, :service_name) + change_column_default :active_storage_blobs, :service_name, nil end end end From 585de110faef6ad042a843c5b3e8e89582901ce0 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 14 Sep 2021 20:32:52 -0700 Subject: [PATCH 080/149] back to this approach --- ...30031_remove_service_name_from_active_storage_blobs.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb b/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb index 53f6dbdf..b09fd0f8 100644 --- a/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb +++ b/db/migrate/20210915030031_remove_service_name_from_active_storage_blobs.rb @@ -1,13 +1,7 @@ class RemoveServiceNameFromActiveStorageBlobs < ActiveRecord::Migration[6.0] def up if column_exists?(:active_storage_blobs, :service_name) - change_column_default :active_storage_blobs, :service_name, "amazon" - end - end - - def down - if column_exists?(:active_storage_blobs, :service_name) - change_column_default :active_storage_blobs, :service_name, nil + remove_column :active_storage_blobs, :service_name end end end From 3c1b3f652042d4a853c1e5fb09008978d4595308 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 15 Sep 2021 11:45:02 -0700 Subject: [PATCH 081/149] Revert "Revert "Bump rails from 6.0.3.2 to 6.0.3.4"" This reverts commit 8ab29a6c83f4f9f4bda2fb1d52880f8e21d94552. --- Gemfile.lock | 96 ++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1aaf9a8d..cbf4b0be 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,38 +41,38 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.0.3.2) - actionpack (= 6.0.3.2) + actioncable (6.0.3.4) + actionpack (= 6.0.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3.2) - actionpack (= 6.0.3.2) - activejob (= 6.0.3.2) - activerecord (= 6.0.3.2) - activestorage (= 6.0.3.2) - activesupport (= 6.0.3.2) + actionmailbox (6.0.3.4) + actionpack (= 6.0.3.4) + activejob (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) mail (>= 2.7.1) - actionmailer (6.0.3.2) - actionpack (= 6.0.3.2) - actionview (= 6.0.3.2) - activejob (= 6.0.3.2) + actionmailer (6.0.3.4) + actionpack (= 6.0.3.4) + actionview (= 6.0.3.4) + activejob (= 6.0.3.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3.2) - actionview (= 6.0.3.2) - activesupport (= 6.0.3.2) + actionpack (6.0.3.4) + actionview (= 6.0.3.4) + activesupport (= 6.0.3.4) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3.2) - actionpack (= 6.0.3.2) - activerecord (= 6.0.3.2) - activestorage (= 6.0.3.2) - activesupport (= 6.0.3.2) + actiontext (6.0.3.4) + actionpack (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) nokogiri (>= 1.8.5) - actionview (6.0.3.2) - activesupport (= 6.0.3.2) + actionview (6.0.3.4) + activesupport (= 6.0.3.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -81,24 +81,24 @@ GEM activerecord (>= 4.0) active_storage_validations (0.9.5) rails (>= 5.2.0) - activejob (6.0.3.2) - activesupport (= 6.0.3.2) + activejob (6.0.3.4) + activesupport (= 6.0.3.4) globalid (>= 0.3.6) - activemodel (6.0.3.2) - activesupport (= 6.0.3.2) + activemodel (6.0.3.4) + activesupport (= 6.0.3.4) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.0.3.2) - activemodel (= 6.0.3.2) - activesupport (= 6.0.3.2) - activestorage (6.0.3.2) - actionpack (= 6.0.3.2) - activejob (= 6.0.3.2) - activerecord (= 6.0.3.2) + activerecord (6.0.3.4) + activemodel (= 6.0.3.4) + activesupport (= 6.0.3.4) + activestorage (6.0.3.4) + actionpack (= 6.0.3.4) + activejob (= 6.0.3.4) + activerecord (= 6.0.3.4) marcel (~> 0.3.1) - activesupport (6.0.3.2) + activesupport (6.0.3.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -1390,20 +1390,20 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.0.3.2) - actioncable (= 6.0.3.2) - actionmailbox (= 6.0.3.2) - actionmailer (= 6.0.3.2) - actionpack (= 6.0.3.2) - actiontext (= 6.0.3.2) - actionview (= 6.0.3.2) - activejob (= 6.0.3.2) - activemodel (= 6.0.3.2) - activerecord (= 6.0.3.2) - activestorage (= 6.0.3.2) - activesupport (= 6.0.3.2) + rails (6.0.3.4) + actioncable (= 6.0.3.4) + actionmailbox (= 6.0.3.4) + actionmailer (= 6.0.3.4) + actionpack (= 6.0.3.4) + actiontext (= 6.0.3.4) + actionview (= 6.0.3.4) + activejob (= 6.0.3.4) + activemodel (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) bundler (>= 1.3.0) - railties (= 6.0.3.2) + railties (= 6.0.3.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -1490,7 +1490,7 @@ GEM babel-source (>= 5.8.11) babel-transpiler sprockets (>= 3.0.0) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) From e61c250edec9ff08ab878e020a606b5074307a64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Sep 2021 12:00:39 +0000 Subject: [PATCH 082/149] Bump aws-sdk-s3 from 1.96.1 to 1.103.0 Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.96.1 to 1.103.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) --- updated-dependencies: - dependency-name: aws-sdk-s3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cbf4b0be..dba8685a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -114,8 +114,8 @@ GEM activesupport (>= 3.0.0) autoprefixer-rails (9.8.4) execjs - aws-eventstream (1.1.1) - aws-partitions (1.469.0) + aws-eventstream (1.2.0) + aws-partitions (1.502.0) aws-sdk (3.0.2) aws-sdk-resources (~> 3) aws-sdk-accessanalyzer (1.17.0) @@ -301,7 +301,7 @@ GEM aws-sdk-connectparticipant (1.11.0) aws-sdk-core (~> 3, >= 3.112.0) aws-sigv4 (~> 1.1) - aws-sdk-core (3.114.3) + aws-sdk-core (3.121.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) @@ -552,8 +552,8 @@ GEM aws-sdk-kinesisvideosignalingchannels (1.10.0) aws-sdk-core (~> 3, >= 3.112.0) aws-sigv4 (~> 1.1) - aws-sdk-kms (1.44.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kms (1.48.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) aws-sdk-lakeformation (1.13.0) aws-sdk-core (~> 3, >= 3.112.0) @@ -1009,10 +1009,10 @@ GEM aws-sdk-route53resolver (1.24.0) aws-sdk-core (~> 3, >= 3.112.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.96.1) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-s3 (1.103.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.1) + aws-sigv4 (~> 1.4) aws-sdk-s3control (1.30.0) aws-sdk-core (~> 3, >= 3.112.0) aws-sigv4 (~> 1.1) @@ -1158,7 +1158,7 @@ GEM aws-sdk-core (~> 3, >= 3.112.0) aws-sigv4 (~> 1.1) aws-sigv2 (1.0.2) - aws-sigv4 (1.2.3) + aws-sigv4 (1.4.0) aws-eventstream (~> 1, >= 1.0.2) babel-source (5.8.35) babel-transpiler (0.7.0) From 3e22c2b4fc6876fe185590265f3d9fde6d286f0d Mon Sep 17 00:00:00 2001 From: drusepth Date: Fri, 17 Sep 2021 14:25:32 -0700 Subject: [PATCH 083/149] switch to more inclusive AF params --- app/controllers/attribute_fields_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/attribute_fields_controller.rb b/app/controllers/attribute_fields_controller.rb index 21e377fb..bd717aa3 100644 --- a/app/controllers/attribute_fields_controller.rb +++ b/app/controllers/attribute_fields_controller.rb @@ -26,7 +26,7 @@ class AttributeFieldsController < ContentController return redirect_back fallback_location: root_path end - if @attribute_field.update(attribute_field_params.merge({ migrated_from_legacy: true })) + if @attribute_field.update(content_params.merge({ migrated_from_legacy: true })) @content = @attribute_field successful_response( @attribute_field, From 5ce62b0dde31405d918d8a7edd94c97b53e728ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Sep 2021 08:09:11 +0000 Subject: [PATCH 084/149] Bump axios from 0.21.1 to 0.21.2 Bumps [axios](https://github.com/axios/axios) from 0.21.1 to 0.21.2. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v0.21.1...v0.21.2) --- updated-dependencies: - dependency-name: axios dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index c62bec02..16d147c5 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "@material-ui/lab": "^4.0.0-alpha.41", "@rails/webpacker": "^5.2.1", "@types/react": "^17.0.13", - "axios": "^0.21.1", + "axios": "^0.21.2", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "pluralize": "^8.0.0", "prop-types": "^15.7.2", diff --git a/yarn.lock b/yarn.lock index 5975e7c7..5b56b5ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1478,12 +1478,12 @@ autoprefixer@^9.6.1: postcss "^7.0.32" postcss-value-parser "^4.1.0" -axios@^0.21.1: - version "0.21.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" - integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== +axios@^0.21.2: + version "0.21.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017" + integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg== dependencies: - follow-redirects "^1.10.0" + follow-redirects "^1.14.0" babel-loader@^8.2.2: version "8.2.2" @@ -3084,10 +3084,10 @@ flush-write-stream@^1.0.0: inherits "^2.0.3" readable-stream "^2.3.6" -follow-redirects@^1.0.0, follow-redirects@^1.10.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43" - integrity sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg== +follow-redirects@^1.0.0, follow-redirects@^1.14.0: + version "1.14.4" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" + integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g== for-in@^1.0.2: version "1.0.2" From 38dc95fd10c7f9649f79cacfa7248b9c850c58a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Sep 2021 08:09:28 +0000 Subject: [PATCH 085/149] Bump url-parse from 1.5.1 to 1.5.3 Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.1 to 1.5.3. - [Release notes](https://github.com/unshiftio/url-parse/releases) - [Commits](https://github.com/unshiftio/url-parse/compare/1.5.1...1.5.3) --- updated-dependencies: - dependency-name: url-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5975e7c7..0546226a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6841,9 +6841,9 @@ urix@^0.1.0: integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= url-parse@^1.4.3, url-parse@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.1.tgz#d5fa9890af8a5e1f274a2c98376510f6425f6e3b" - integrity sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q== + version "1.5.3" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.3.tgz#71c1303d38fb6639ade183c2992c8cc0686df862" + integrity sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ== dependencies: querystringify "^2.1.1" requires-port "^1.0.0" From 40bd5ef2d0dd6b7d1298bddec7b67ce02374f885 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Sep 2021 08:11:26 +0000 Subject: [PATCH 086/149] Bump meta-tags from 2.14.0 to 2.15.0 Bumps [meta-tags](https://github.com/kpumuk/meta-tags) from 2.14.0 to 2.15.0. - [Release notes](https://github.com/kpumuk/meta-tags/releases) - [Changelog](https://github.com/kpumuk/meta-tags/blob/main/CHANGELOG.md) - [Commits](https://github.com/kpumuk/meta-tags/compare/v2.14.0...v2.15.0) --- updated-dependencies: - dependency-name: meta-tags dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f7addd19..2fda48bb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1307,7 +1307,7 @@ GEM listen (3.7.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.11.0) + loofah (2.12.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -1319,7 +1319,7 @@ GEM medium-editor-rails (2.3.1) railties (>= 3.0) memory_profiler (1.0.0) - meta-tags (2.14.0) + meta-tags (2.15.0) actionpack (>= 3.2.0, < 6.2) method_source (1.0.0) mime-types (3.3.1) @@ -1340,7 +1340,7 @@ GEM nested_form (0.3.2) newrelic_rpm (7.2.0) nio4r (2.5.8) - nokogiri (1.12.2) + nokogiri (1.12.4) mini_portile2 (~> 2.6.1) racc (~> 1.4) nokogumbo (2.0.2) @@ -1408,7 +1408,7 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) + rails-html-sanitizer (1.4.2) loofah (~> 2.3) rails-jquery-autocomplete (1.0.5) rails (>= 3.2) From a5e682fb3bd630585511e6b8c1de0e250f9c3788 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Sep 2021 08:34:44 +0000 Subject: [PATCH 087/149] Bump bundler-audit from 0.8.0 to 0.9.0.1 Bumps [bundler-audit](https://github.com/postmodern/bundler-audit) from 0.8.0 to 0.9.0.1. - [Release notes](https://github.com/postmodern/bundler-audit/releases) - [Changelog](https://github.com/rubysec/bundler-audit/blob/master/ChangeLog.md) - [Commits](https://github.com/postmodern/bundler-audit/compare/v0.8.0...v0.9.0.1) --- updated-dependencies: - dependency-name: bundler-audit dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2fda48bb..9416d139 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1175,7 +1175,7 @@ GEM bullet (6.1.5) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) - bundler-audit (0.8.0) + bundler-audit (0.9.0.1) bundler (>= 1.2.0, < 3) thor (~> 1.0) chartkick (4.0.5) From 81d9bfe7e0e095f0dfd1f05d71386a9a26c03303 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Sep 2021 08:34:45 +0000 Subject: [PATCH 088/149] Bump rack-mini-profiler from 2.3.2 to 2.3.3 Bumps [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler) from 2.3.2 to 2.3.3. - [Release notes](https://github.com/MiniProfiler/rack-mini-profiler/releases) - [Changelog](https://github.com/MiniProfiler/rack-mini-profiler/blob/master/CHANGELOG.md) - [Commits](https://github.com/MiniProfiler/rack-mini-profiler/compare/v2.3.2...v2.3.3) --- updated-dependencies: - dependency-name: rack-mini-profiler dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2fda48bb..61a2ca62 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1381,7 +1381,7 @@ GEM activesupport (>= 3.0.0) racc (1.5.2) rack (2.2.3) - rack-mini-profiler (2.3.2) + rack-mini-profiler (2.3.3) rack (>= 1.2.0) rack-pjax (1.1.0) nokogiri (~> 1.5) From 7a93b80c4225f74f769de3889cb2ec59caf3f062 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Sep 2021 08:34:45 +0000 Subject: [PATCH 089/149] Bump sidekiq from 6.2.1 to 6.2.2 Bumps [sidekiq](https://github.com/mperham/sidekiq) from 6.2.1 to 6.2.2. - [Release notes](https://github.com/mperham/sidekiq/releases) - [Changelog](https://github.com/mperham/sidekiq/blob/master/Changes.md) - [Commits](https://github.com/mperham/sidekiq/compare/v6.2.1...v6.2.2) --- updated-dependencies: - dependency-name: sidekiq dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2fda48bb..12dd1f21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1193,7 +1193,7 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.1.9) - connection_pool (2.2.3) + connection_pool (2.2.5) crass (1.0.6) csv (3.2.0) d3-rails (5.9.2) @@ -1473,7 +1473,7 @@ GEM childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) semantic_range (3.0.0) - sidekiq (6.2.1) + sidekiq (6.2.2) connection_pool (>= 2.2.2) rack (~> 2.0) redis (>= 4.2.0) From e2111d440373de5a0e9b18dca102ae98ed5b9097 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Sep 2021 08:34:47 +0000 Subject: [PATCH 090/149] Bump aws-sdk from 3.0.2 to 3.1.0 Bumps [aws-sdk](https://github.com/aws/aws-sdk-ruby) from 3.0.2 to 3.1.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) --- updated-dependencies: - dependency-name: aws-sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 1118 +++++++++++++++++++++++++++----------------------- 2 files changed, 602 insertions(+), 518 deletions(-) diff --git a/Gemfile b/Gemfile index 58b0dd10..b453ddd5 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'puma-heroku' gem 'sprockets', '~> 3.7.2' # Storage -gem 'aws-sdk', '~> 3.0' +gem 'aws-sdk', '~> 3.1' gem 'aws-sdk-s3' gem 'filesize' diff --git a/Gemfile.lock b/Gemfile.lock index 2fda48bb..b00241ba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -115,630 +115,675 @@ GEM autoprefixer-rails (9.8.4) execjs aws-eventstream (1.2.0) - aws-partitions (1.502.0) - aws-sdk (3.0.2) + aws-partitions (1.503.0) + aws-sdk (3.1.0) aws-sdk-resources (~> 3) - aws-sdk-accessanalyzer (1.17.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-accessanalyzer (1.23.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-acm (1.41.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-acm (1.45.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-acmpca (1.34.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-acmpca (1.40.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-alexaforbusiness (1.46.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-alexaforbusiness (1.50.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-amplify (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-amplify (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-amplifybackend (1.3.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-amplifybackend (1.8.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-apigateway (1.61.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-apigateway (1.67.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-apigatewaymanagementapi (1.21.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-apigatewaymanagementapi (1.24.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-apigatewayv2 (1.32.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-apigatewayv2 (1.36.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-appconfig (1.14.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-appconfig (1.17.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-appflow (1.9.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-appflow (1.15.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-appintegrationsservice (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-appintegrationsservice (1.6.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-applicationautoscaling (1.51.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-applicationautoscaling (1.55.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-applicationdiscoveryservice (1.35.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-applicationcostprofiler (1.3.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-applicationinsights (1.18.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-applicationdiscoveryservice (1.38.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-appmesh (1.35.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-applicationinsights (1.21.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-appregistry (1.5.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-appmesh (1.39.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-appstream (1.51.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-appregistry (1.8.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-appsync (1.40.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-apprunner (1.3.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-athena (1.37.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-appstream (1.55.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-auditmanager (1.4.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-appsync (1.43.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-augmentedairuntime (1.12.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-athena (1.41.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-autoscaling (1.58.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-auditmanager (1.11.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-autoscalingplans (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-augmentedairuntime (1.16.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-backup (1.28.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-autoscaling (1.68.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-batch (1.45.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-autoscalingplans (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-braket (1.7.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-backup (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-budgets (1.38.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-batch (1.51.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-chime (1.42.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-braket (1.11.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloud9 (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-budgets (1.41.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-clouddirectory (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-chime (1.57.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudformation (1.49.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-chimesdkidentity (1.2.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudfront (1.49.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-chimesdkmessaging (1.2.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudhsm (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloud9 (1.39.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudhsmv2 (1.33.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-clouddirectory (1.35.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudsearch (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudformation (1.58.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudsearchdomain (1.24.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudfront (1.56.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudtrail (1.34.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudhsm (1.33.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudwatch (1.50.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudhsmv2 (1.36.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudwatchevents (1.44.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudsearch (1.33.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cloudwatchlogs (1.40.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudsearchdomain (1.27.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codeartifact (1.8.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudtrail (1.38.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codebuild (1.71.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudwatch (1.55.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codecommit (1.42.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudwatchevents (1.51.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codedeploy (1.39.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cloudwatchlogs (1.45.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codeguruprofiler (1.15.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codeartifact (1.13.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codegurureviewer (1.16.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codebuild (1.81.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codepipeline (1.44.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codecommit (1.45.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codestar (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codedeploy (1.43.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codestarconnections (1.14.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codeguruprofiler (1.18.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-codestarnotifications (1.10.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codegurureviewer (1.23.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cognitoidentity (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codepipeline (1.47.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cognitoidentityprovider (1.50.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codestar (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-cognitosync (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codestarconnections (1.18.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-comprehend (1.45.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-codestarnotifications (1.13.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-comprehendmedical (1.25.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cognitoidentity (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-computeoptimizer (1.16.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cognitoidentityprovider (1.57.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-configservice (1.59.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-cognitosync (1.30.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-connect (1.42.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-comprehend (1.51.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-connectcontactlens (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-comprehendmedical (1.29.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-connectparticipant (1.11.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-computeoptimizer (1.24.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-configservice (1.66.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-connect (1.50.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-connectcontactlens (1.5.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-connectparticipant (1.14.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) aws-sdk-core (3.121.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-costandusagereportservice (1.30.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-costandusagereportservice (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-costexplorer (1.59.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-costexplorer (1.66.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-customerprofiles (1.4.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-customerprofiles (1.11.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-databasemigrationservice (1.52.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-databasemigrationservice (1.59.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-dataexchange (1.13.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-dataexchange (1.16.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-datapipeline (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-datapipeline (1.30.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-datasync (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-datasync (1.36.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-dax (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-dax (1.33.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-detective (1.15.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-detective (1.21.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-devicefarm (1.41.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-devicefarm (1.45.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-devopsguru (1.5.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-devopsguru (1.11.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-directconnect (1.40.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-directconnect (1.46.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-directoryservice (1.39.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-directoryservice (1.43.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-dlm (1.40.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-dlm (1.44.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-docdb (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-docdb (1.35.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-dynamodb (1.60.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-dynamodb (1.63.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-dynamodbstreams (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-dynamodbstreams (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ebs (1.13.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ebs (1.18.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ec2 (1.227.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ec2 (1.263.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ec2instanceconnect (1.13.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ec2instanceconnect (1.17.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ecr (1.42.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ecr (1.46.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ecrpublic (1.3.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ecrpublic (1.6.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ecs (1.75.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ecs (1.85.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-efs (1.39.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-efs (1.44.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-eks (1.51.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-eks (1.63.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-elasticache (1.54.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-elasticache (1.62.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-elasticbeanstalk (1.42.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-elasticbeanstalk (1.45.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-elasticinference (1.12.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-elasticinference (1.15.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-elasticloadbalancing (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-elasticloadbalancing (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-elasticloadbalancingv2 (1.61.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-elasticloadbalancingv2 (1.67.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-elasticsearchservice (1.51.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-elasticsearchservice (1.56.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-elastictranscoder (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-elastictranscoder (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-emr (1.44.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-emr (1.52.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-emrcontainers (1.3.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-emrcontainers (1.7.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-eventbridge (1.22.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-eventbridge (1.30.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-firehose (1.37.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-finspace (1.5.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-fms (1.35.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-finspacedata (1.4.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-forecastqueryservice (1.12.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-firehose (1.41.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-forecastservice (1.17.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-fis (1.4.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-frauddetector (1.17.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-fms (1.41.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-fsx (1.35.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-forecastqueryservice (1.15.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-gamelift (1.42.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-forecastservice (1.25.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-glacier (1.37.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-frauddetector (1.24.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-globalaccelerator (1.30.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-fsx (1.42.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-glue (1.85.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-gamelift (1.47.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-gluedatabrew (1.6.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-glacier (1.40.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-greengrass (1.39.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-globalaccelerator (1.33.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-greengrassv2 (1.3.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-glue (1.95.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-groundstation (1.17.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-gluedatabrew (1.13.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-guardduty (1.45.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-greengrass (1.43.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-health (1.34.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-greengrassv2 (1.8.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-healthlake (1.3.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-groundstation (1.21.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-honeycode (1.6.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-guardduty (1.48.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iam (1.49.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-health (1.39.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-identitystore (1.5.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-healthlake (1.7.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-imagebuilder (1.20.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-honeycode (1.9.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-importexport (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iam (1.60.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-identitystore (1.9.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-imagebuilder (1.29.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-importexport (1.29.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv2 (~> 1.0) - aws-sdk-inspector (1.34.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-inspector (1.37.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iot (1.67.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iot (1.75.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iot1clickdevicesservice (1.28.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iot1clickdevicesservice (1.31.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iot1clickprojects (1.28.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iot1clickprojects (1.31.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotanalytics (1.38.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotanalytics (1.43.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotdataplane (1.28.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotdataplane (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotdeviceadvisor (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotdeviceadvisor (1.6.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotevents (1.23.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotevents (1.27.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ioteventsdata (1.15.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ioteventsdata (1.19.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotfleethub (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotfleethub (1.5.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotjobsdataplane (1.27.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotjobsdataplane (1.30.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotsecuretunneling (1.11.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotsecuretunneling (1.14.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotsitewise (1.20.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotsitewise (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotthingsgraph (1.14.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotthingsgraph (1.17.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-iotwireless (1.5.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-iotwireless (1.14.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ivs (1.8.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ivs (1.12.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-kafka (1.35.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kafka (1.40.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-kendra (1.22.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kafkaconnect (1.0.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-kinesis (1.32.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kendra (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-kinesisanalytics (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kinesis (1.35.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-kinesisanalyticsv2 (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kinesisanalytics (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-kinesisvideo (1.32.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kinesisanalyticsv2 (1.33.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-kinesisvideoarchivedmedia (1.33.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kinesisvideo (1.35.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-kinesisvideomedia (1.28.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kinesisvideoarchivedmedia (1.37.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-kinesisvideosignalingchannels (1.10.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kinesisvideomedia (1.31.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-kinesisvideosignalingchannels (1.13.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) aws-sdk-kms (1.48.0) aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-lakeformation (1.13.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lakeformation (1.17.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-lambda (1.61.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lambda (1.68.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-lambdapreview (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lambdapreview (1.29.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-lex (1.35.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lex (1.39.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-lexmodelbuildingservice (1.44.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lexmodelbuildingservice (1.51.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-lexmodelsv2 (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lexmodelsv2 (1.10.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-lexruntimev2 (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lexruntimev2 (1.6.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-licensemanager (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-licensemanager (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-lightsail (1.46.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lightsail (1.56.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-locationservice (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-locationservice (1.8.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-lookoutforvision (1.3.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lookoutequipment (1.4.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-machinelearning (1.27.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lookoutforvision (1.6.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-macie (1.28.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-lookoutmetrics (1.7.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-macie2 (1.25.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-machinelearning (1.31.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-managedblockchain (1.22.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-macie (1.31.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-marketplacecatalog (1.11.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-macie2 (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-marketplacecommerceanalytics (1.32.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-managedblockchain (1.26.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-marketplaceentitlementservice (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-marketplacecatalog (1.15.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-marketplacemetering (1.34.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-marketplacecommerceanalytics (1.35.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mediaconnect (1.30.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-marketplaceentitlementservice (1.29.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mediaconvert (1.64.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-marketplacemetering (1.37.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-medialive (1.67.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mediaconnect (1.37.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mediapackage (1.38.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mediaconvert (1.74.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mediapackagevod (1.22.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-medialive (1.76.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mediastore (1.32.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mediapackage (1.44.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mediastoredata (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mediapackagevod (1.27.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mediatailor (1.36.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mediastore (1.35.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-migrationhub (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mediastoredata (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-migrationhubconfig (1.11.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mediatailor (1.44.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mobile (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-memorydb (1.2.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mq (1.36.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mgn (1.4.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mturk (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-migrationhub (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-mwaa (1.3.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-migrationhubconfig (1.14.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-neptune (1.34.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mobile (1.29.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-networkfirewall (1.4.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mq (1.40.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-networkmanager (1.11.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mturk (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-opsworks (1.32.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-mwaa (1.8.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-opsworkscm (1.42.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-neptune (1.38.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-organizations (1.58.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-networkfirewall (1.7.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-outposts (1.15.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-networkmanager (1.14.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-personalize (1.22.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-nimblestudio (1.5.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-personalizeevents (1.17.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-opensearchservice (1.1.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-personalizeruntime (1.22.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-opsworks (1.35.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-pi (1.27.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-opsworkscm (1.46.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-pinpoint (1.52.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-organizations (1.62.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-pinpointemail (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-outposts (1.21.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-pinpointsmsvoice (1.23.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-personalize (1.31.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-polly (1.40.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-personalizeevents (1.21.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-pricing (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-personalizeruntime (1.25.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-prometheusservice (1.3.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-pi (1.31.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-qldb (1.13.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-pinpoint (1.57.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-qldbsession (1.13.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-pinpointemail (1.29.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-quicksight (1.44.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-pinpointsmsvoice (1.26.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ram (1.24.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-polly (1.46.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-rds (1.117.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-pricing (1.31.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-rdsdataservice (1.25.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-prometheusservice (1.7.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-redshift (1.55.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-proton (1.7.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-redshiftdataapiservice (1.6.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-qldb (1.19.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-rekognition (1.49.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-qldbsession (1.16.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-resourcegroups (1.35.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-quicksight (1.54.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-resourcegroupstaggingapi (1.37.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ram (1.30.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-resources (3.94.1) + aws-sdk-rds (1.127.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-rdsdataservice (1.28.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-redshift (1.69.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-redshiftdataapiservice (1.11.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-rekognition (1.56.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-resourcegroups (1.39.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-resourcegroupstaggingapi (1.40.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-resources (3.112.0) aws-sdk-accessanalyzer (~> 1) aws-sdk-acm (~> 1) aws-sdk-acmpca (~> 1) @@ -752,10 +797,12 @@ GEM aws-sdk-appflow (~> 1) aws-sdk-appintegrationsservice (~> 1) aws-sdk-applicationautoscaling (~> 1) + aws-sdk-applicationcostprofiler (~> 1) aws-sdk-applicationdiscoveryservice (~> 1) aws-sdk-applicationinsights (~> 1) aws-sdk-appmesh (~> 1) aws-sdk-appregistry (~> 1) + aws-sdk-apprunner (~> 1) aws-sdk-appstream (~> 1) aws-sdk-appsync (~> 1) aws-sdk-athena (~> 1) @@ -768,6 +815,8 @@ GEM aws-sdk-braket (~> 1) aws-sdk-budgets (~> 1) aws-sdk-chime (~> 1) + aws-sdk-chimesdkidentity (~> 1) + aws-sdk-chimesdkmessaging (~> 1) aws-sdk-cloud9 (~> 1) aws-sdk-clouddirectory (~> 1) aws-sdk-cloudformation (~> 1) @@ -835,7 +884,10 @@ GEM aws-sdk-emr (~> 1) aws-sdk-emrcontainers (~> 1) aws-sdk-eventbridge (~> 1) + aws-sdk-finspace (~> 1) + aws-sdk-finspacedata (~> 1) aws-sdk-firehose (~> 1) + aws-sdk-fis (~> 1) aws-sdk-fms (~> 1) aws-sdk-forecastqueryservice (~> 1) aws-sdk-forecastservice (~> 1) @@ -874,6 +926,7 @@ GEM aws-sdk-iotwireless (~> 1) aws-sdk-ivs (~> 1) aws-sdk-kafka (~> 1) + aws-sdk-kafkaconnect (~> 1) aws-sdk-kendra (~> 1) aws-sdk-kinesis (~> 1) aws-sdk-kinesisanalytics (~> 1) @@ -893,7 +946,9 @@ GEM aws-sdk-licensemanager (~> 1) aws-sdk-lightsail (~> 1) aws-sdk-locationservice (~> 1) + aws-sdk-lookoutequipment (~> 1) aws-sdk-lookoutforvision (~> 1) + aws-sdk-lookoutmetrics (~> 1) aws-sdk-machinelearning (~> 1) aws-sdk-macie (~> 1) aws-sdk-macie2 (~> 1) @@ -910,6 +965,8 @@ GEM aws-sdk-mediastore (~> 1) aws-sdk-mediastoredata (~> 1) aws-sdk-mediatailor (~> 1) + aws-sdk-memorydb (~> 1) + aws-sdk-mgn (~> 1) aws-sdk-migrationhub (~> 1) aws-sdk-migrationhubconfig (~> 1) aws-sdk-mobile (~> 1) @@ -919,6 +976,8 @@ GEM aws-sdk-neptune (~> 1) aws-sdk-networkfirewall (~> 1) aws-sdk-networkmanager (~> 1) + aws-sdk-nimblestudio (~> 1) + aws-sdk-opensearchservice (~> 1) aws-sdk-opsworks (~> 1) aws-sdk-opsworkscm (~> 1) aws-sdk-organizations (~> 1) @@ -933,6 +992,7 @@ GEM aws-sdk-polly (~> 1) aws-sdk-pricing (~> 1) aws-sdk-prometheusservice (~> 1) + aws-sdk-proton (~> 1) aws-sdk-qldb (~> 1) aws-sdk-qldbsession (~> 1) aws-sdk-quicksight (~> 1) @@ -947,6 +1007,9 @@ GEM aws-sdk-robomaker (~> 1) aws-sdk-route53 (~> 1) aws-sdk-route53domains (~> 1) + aws-sdk-route53recoverycluster (~> 1) + aws-sdk-route53recoverycontrolconfig (~> 1) + aws-sdk-route53recoveryreadiness (~> 1) aws-sdk-route53resolver (~> 1) aws-sdk-s3 (~> 1) aws-sdk-s3control (~> 1) @@ -970,9 +1033,12 @@ GEM aws-sdk-simpledb (~> 1) aws-sdk-sms (~> 1) aws-sdk-snowball (~> 1) + aws-sdk-snowdevicemanagement (~> 1) aws-sdk-sns (~> 1) aws-sdk-sqs (~> 1) aws-sdk-ssm (~> 1) + aws-sdk-ssmcontacts (~> 1) + aws-sdk-ssmincidents (~> 1) aws-sdk-ssoadmin (~> 1) aws-sdk-ssooidc (~> 1) aws-sdk-states (~> 1) @@ -997,167 +1063,185 @@ GEM aws-sdk-workmailmessageflow (~> 1) aws-sdk-workspaces (~> 1) aws-sdk-xray (~> 1) - aws-sdk-robomaker (1.34.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-robomaker (1.42.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-route53 (1.47.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-route53 (1.55.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-route53domains (1.30.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-route53domains (1.33.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-route53resolver (1.24.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-route53recoverycluster (1.3.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-route53recoverycontrolconfig (1.3.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-route53recoveryreadiness (1.3.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-route53resolver (1.30.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) aws-sdk-s3 (1.103.0) aws-sdk-core (~> 3, >= 3.120.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) - aws-sdk-s3control (1.30.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-s3control (1.40.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-s3outposts (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-s3outposts (1.6.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-sagemaker (1.81.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-sagemaker (1.101.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-sagemakeredgemanager (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-sagemakeredgemanager (1.5.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-sagemakerfeaturestoreruntime (1.2.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-sagemakerfeaturestoreruntime (1.6.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-sagemakerruntime (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-sagemakerruntime (1.35.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-savingsplans (1.14.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-savingsplans (1.19.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-schemas (1.12.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-schemas (1.16.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-secretsmanager (1.46.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-secretsmanager (1.49.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-securityhub (1.41.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-securityhub (1.52.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-serverlessapplicationrepository (1.34.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-serverlessapplicationrepository (1.37.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-servicecatalog (1.59.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-servicecatalog (1.63.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-servicediscovery (1.34.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-servicediscovery (1.40.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-servicequotas (1.14.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-servicequotas (1.17.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ses (1.38.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ses (1.41.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-sesv2 (1.17.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-sesv2 (1.20.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-shield (1.36.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-shield (1.41.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-signer (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-signer (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-simpledb (1.26.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-simpledb (1.29.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv2 (~> 1.0) - aws-sdk-sms (1.29.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-sms (1.32.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-snowball (1.37.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-snowball (1.42.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-sns (1.39.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-snowdevicemanagement (1.1.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-sqs (1.37.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-sns (1.45.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ssm (1.106.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-sqs (1.44.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ssoadmin (1.7.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ssm (1.117.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-ssooidc (1.10.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ssmcontacts (1.7.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-states (1.39.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ssmincidents (1.4.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-storagegateway (1.54.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ssoadmin (1.10.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-support (1.30.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-ssooidc (1.13.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-swf (1.27.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-states (1.42.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-synthetics (1.12.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-storagegateway (1.59.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-textract (1.24.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-support (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-timestreamquery (1.4.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-swf (1.30.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-timestreamwrite (1.4.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-synthetics (1.17.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-transcribeservice (1.52.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-textract (1.28.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-transcribestreamingservice (1.27.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-timestreamquery (1.7.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-transfer (1.32.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-timestreamwrite (1.7.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-translate (1.31.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-transcribeservice (1.63.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-waf (1.38.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-transcribestreamingservice (1.33.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-wafregional (1.39.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-transfer (1.39.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-wafv2 (1.18.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-translate (1.34.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-wellarchitected (1.4.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-waf (1.41.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-workdocs (1.30.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-wafregional (1.42.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-worklink (1.23.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-wafv2 (1.26.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-workmail (1.36.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-wellarchitected (1.8.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-workmailmessageflow (1.12.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-workdocs (1.33.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-workspaces (1.51.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-worklink (1.26.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-xray (1.37.0) - aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-workmail (1.40.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sigv2 (1.0.2) + aws-sdk-workmailmessageflow (1.15.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-workspaces (1.56.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-xray (1.41.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sigv2 (1.1.0) aws-sigv4 (1.4.0) aws-eventstream (~> 1, >= 1.0.2) babel-source (5.8.35) @@ -1547,7 +1631,7 @@ DEPENDENCIES acts_as_list animate-rails authority - aws-sdk (~> 3.0) + aws-sdk (~> 3.1) aws-sdk-s3 barnes binding_of_caller From a00406c20f4534ae4ecf8a2fa9c1af3098baea2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Sep 2021 08:34:47 +0000 Subject: [PATCH 091/149] Bump ibm_watson from 2.1.1 to 2.1.3 Bumps [ibm_watson](https://github.com/watson-developer-cloud/ruby-sdk) from 2.1.1 to 2.1.3. - [Release notes](https://github.com/watson-developer-cloud/ruby-sdk/releases) - [Changelog](https://github.com/watson-developer-cloud/ruby-sdk/blob/master/.releaserc) - [Commits](https://github.com/watson-developer-cloud/ruby-sdk/compare/v2.1.1...v2.1.3) --- updated-dependencies: - dependency-name: ibm_watson dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2fda48bb..ba8432e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1229,7 +1229,7 @@ GEM faye-websocket (0.11.1) eventmachine (>= 0.12.0) websocket-driver (>= 0.5.1) - ffi (1.15.3) + ffi (1.15.4) ffi-compiler (1.0.1) ffi (>= 1.0.0) rake @@ -1253,7 +1253,7 @@ GEM http-cookie (~> 1.0) http-form_data (~> 2.2) http-parser (~> 1.2.0) - http-cookie (1.0.3) + http-cookie (1.0.4) domain_name (~> 0.5) http-form_data (2.3.0) http-parser (1.2.3) @@ -1264,7 +1264,7 @@ GEM concurrent-ruby (~> 1.0) http (~> 4.4.0) jwt (~> 2.2.1) - ibm_watson (2.1.1) + ibm_watson (2.1.3) concurrent-ruby (~> 1.0) eventmachine (~> 1.2) faye-websocket (~> 0.11) @@ -1518,7 +1518,7 @@ GEM execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.7) + unf_ext (0.0.8) uniform_notifier (1.14.2) warden (1.2.9) rack (>= 2.0.9) From c2fd335c5bf2c1c88b026199c185ca8bba8574c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Sep 2021 12:01:24 +0000 Subject: [PATCH 092/149] Bump puma from 5.4.0 to 5.5.0 Bumps [puma](https://github.com/puma/puma) from 5.4.0 to 5.5.0. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v5.4.0...v5.5.0) --- updated-dependencies: - dependency-name: puma dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index b453ddd5..7c0f68b5 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ ruby "~> 2.7" # Server gem 'rails' -gem 'puma', '~> 5.4' +gem 'puma', '~> 5.5' gem 'puma-heroku' # gem 'bootsnap', require: false gem 'sprockets', '~> 3.7.2' diff --git a/Gemfile.lock b/Gemfile.lock index 3d0c4b64..e64dd612 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1457,7 +1457,7 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) - puma (5.4.0) + puma (5.5.0) nio4r (~> 2.0) puma-heroku (2.0.0) puma (>= 5.0, < 6.0) @@ -1668,7 +1668,7 @@ DEPENDENCIES paypal_client pg (~> 1.2) pry - puma (~> 5.4) + puma (~> 5.5) puma-heroku rack-mini-profiler rails From e246e384f27a17eba3120996fbb7ca47fc60da19 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Sep 2021 12:00:46 +0000 Subject: [PATCH 093/149] Bump paypal-checkout-sdk from 1.0.3 to 1.0.4 Bumps [paypal-checkout-sdk](https://github.com/paypal/Checkout-Ruby-SDK) from 1.0.3 to 1.0.4. - [Release notes](https://github.com/paypal/Checkout-Ruby-SDK/releases) - [Commits](https://github.com/paypal/Checkout-Ruby-SDK/compare/1.0.3...1.0.4) --- updated-dependencies: - dependency-name: paypal-checkout-sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3d0c4b64..52daaf99 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1445,13 +1445,13 @@ GEM terrapin (~> 0.6.0) paranoia (2.4.3) activerecord (>= 4.0, < 6.2) - paypal-checkout-sdk (1.0.3) - paypalhttp (~> 1.0.0) + paypal-checkout-sdk (1.0.4) + paypalhttp (~> 1.0.1) paypal_client (0.4.0) activesupport (> 4.2.8) faraday (~> 0.15) faraday_middleware (~> 0.12) - paypalhttp (1.0.0) + paypalhttp (1.0.1) pg (1.2.3) pry (0.14.1) coderay (~> 1.1) From c55d5fac14f0fd109854448bc070f221e0417b7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Sep 2021 12:01:33 +0000 Subject: [PATCH 094/149] Bump meta-tags from 2.15.0 to 2.16.0 Bumps [meta-tags](https://github.com/kpumuk/meta-tags) from 2.15.0 to 2.16.0. - [Release notes](https://github.com/kpumuk/meta-tags/releases) - [Changelog](https://github.com/kpumuk/meta-tags/blob/main/CHANGELOG.md) - [Commits](https://github.com/kpumuk/meta-tags/compare/v2.15.0...v2.16.0) --- updated-dependencies: - dependency-name: meta-tags dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3d0c4b64..5790f365 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1403,8 +1403,8 @@ GEM medium-editor-rails (2.3.1) railties (>= 3.0) memory_profiler (1.0.0) - meta-tags (2.15.0) - actionpack (>= 3.2.0, < 6.2) + meta-tags (2.16.0) + actionpack (>= 3.2.0, < 7.1) method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) From 51fec671b6035cdbe0bb8b54163723cb0a164bcf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Sep 2021 21:23:14 +0000 Subject: [PATCH 095/149] Bump nokogiri from 1.12.4 to 1.12.5 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.12.4 to 1.12.5. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.12.4...v1.12.5) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3d0c4b64..b027146d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1424,7 +1424,7 @@ GEM nested_form (0.3.2) newrelic_rpm (7.2.0) nio4r (2.5.8) - nokogiri (1.12.4) + nokogiri (1.12.5) mini_portile2 (~> 2.6.1) racc (~> 1.4) nokogumbo (2.0.2) From 12fcec41b729df0c0001f2169800c275113ce800 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Sep 2021 19:51:09 +0000 Subject: [PATCH 096/149] Bump newrelic_rpm from 7.2.0 to 8.0.0 Bumps [newrelic_rpm](https://github.com/newrelic/newrelic-ruby-agent) from 7.2.0 to 8.0.0. - [Release notes](https://github.com/newrelic/newrelic-ruby-agent/releases) - [Changelog](https://github.com/newrelic/newrelic-ruby-agent/blob/dev/CHANGELOG.md) - [Commits](https://github.com/newrelic/newrelic-ruby-agent/compare/7.2.0...8.0.0) --- updated-dependencies: - dependency-name: newrelic_rpm dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index b027146d..98539ea8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1422,7 +1422,7 @@ GEM multipart-post (2.1.1) mustache (1.1.1) nested_form (0.3.2) - newrelic_rpm (7.2.0) + newrelic_rpm (8.0.0) nio4r (2.5.8) nokogiri (1.12.5) mini_portile2 (~> 2.6.1) From 25532988da5f439ced26bdd8e6c9a236089c585a Mon Sep 17 00:00:00 2001 From: drusepth Date: Wed, 29 Sep 2021 13:53:24 -0700 Subject: [PATCH 097/149] remove New banner --- app/views/main/_dashboard_header_links.html.erb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/views/main/_dashboard_header_links.html.erb b/app/views/main/_dashboard_header_links.html.erb index c6733984..065f8f7a 100644 --- a/app/views/main/_dashboard_header_links.html.erb +++ b/app/views/main/_dashboard_header_links.html.erb @@ -8,10 +8,6 @@ Docs Documents - -
              - New: Folders, stats, and more -
          <% end %> From 3b1820c39de57b2ded23ba3c38fbb517687d24c7 Mon Sep 17 00:00:00 2001 From: drusepth Date: Wed, 29 Sep 2021 14:27:17 -0700 Subject: [PATCH 098/149] new-server safety & helper methods --- app/services/green_service.rb | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/app/services/green_service.rb b/app/services/green_service.rb index 6fdade0f..ccf9fd18 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -45,7 +45,7 @@ class GreenService < Service end def self.trees_saved_by(worldbuilding_page_type) - (physical_pages_equivalent_for(worldbuilding_page_type) * worldbuilding_page_type.constantize.last.id) / SHEETS_OF_PAPER_PER_TREE.to_f + (physical_pages_equivalent_for(worldbuilding_page_type) * (worldbuilding_page_type.constantize.last.try(:id) || 0)) / SHEETS_OF_PAPER_PER_TREE.to_f end def self.total_document_pages_equivalent @@ -63,7 +63,7 @@ class GreenService < Service end def self.total_timeline_pages_equivalent - (TimelineEvent.last.id / AVERAGE_TIMELINE_EVENTS_PER_PAGE.to_f).to_i + ((TimelineEvent.last.try(:id) || 0) / AVERAGE_TIMELINE_EVENTS_PER_PAGE.to_f).to_i end def self.total_physical_pages_equivalent(content_type) @@ -76,4 +76,32 @@ class GreenService < Service GreenService.physical_pages_equivalent_for(content_type.name) * (content_type.last.try(:id) || 0) end end + + def self.total_pages_saved_by(user) + total_pages = 0 + + user.content.each do |content_type, content_list| + physical_page_equivalent_for_content_type = case content_type + when 'Timeline' + AVERAGE_TIMELINE_EVENTS_PER_PAGE * TimelineEvent.where(timeline_id: content_list.map(&:id)).count + + when 'Document' + [ + content_list.inject(0) { |sum, doc| sum + (doc.cached_word_count || 0) } / GreenService::AVERAGE_WORDS_PER_PAGE.to_f, + content_list_count + ].max + + else + physical_pages_equivalent_for(content_type) * content_list.count + end + + total_pages += physical_page_equivalent_for_content_type + end + + total_pages + end + + def self.total_trees_saved_by(user) + total_pages_saved_by(user).to_f / GreenService::SHEETS_OF_PAPER_PER_TREE + end end \ No newline at end of file From fa848f86c4562f2b9f2f2a988d448bb6a976cb9c Mon Sep 17 00:00:00 2001 From: drusepth Date: Wed, 29 Sep 2021 15:29:32 -0700 Subject: [PATCH 099/149] add rake one_off:trees task for savings notifications --- lib/tasks/one_off.rake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/tasks/one_off.rake b/lib/tasks/one_off.rake index 879b652a..10ca344b 100644 --- a/lib/tasks/one_off.rake +++ b/lib/tasks/one_off.rake @@ -1,4 +1,23 @@ namespace :one_off do + desc "Alert users who've saved at least one tree" + task trees_notification: :environment do + User.find_each do |user| + trees = GreenService.total_trees_saved_by(user) + + if trees >= 1 + user = User.first + user.notifications.create!( + message_html: "
          You've saved #{trees.round} tree#{'s' if trees.round > 1} by going digital!
          That's AWESOME! Click here to see how.
          ", + icon: 'park', + icon_color: 'green', + happened_at: DateTime.current, + passthrough_link: 'https://www.notebook.ai/my/data/green', + reference_code: 'green-trees' + ) unless user.notifications.where(reference_code: 'green-trees').any? + end + end + end + desc "Create a notification for all users telling them about the new notifications" task notifications_announcement: :environment do User.all.find_each do |user| From 2505e054c7a2feea68e755f9209eacb1cf0f11d3 Mon Sep 17 00:00:00 2001 From: drusepth Date: Wed, 29 Sep 2021 15:38:05 -0700 Subject: [PATCH 100/149] ref code --- lib/tasks/one_off.rake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tasks/one_off.rake b/lib/tasks/one_off.rake index 10ca344b..7d50d32d 100644 --- a/lib/tasks/one_off.rake +++ b/lib/tasks/one_off.rake @@ -1,6 +1,8 @@ namespace :one_off do desc "Alert users who've saved at least one tree" task trees_notification: :environment do + reference_code = 'green-trees' + User.find_each do |user| trees = GreenService.total_trees_saved_by(user) @@ -12,8 +14,8 @@ namespace :one_off do icon_color: 'green', happened_at: DateTime.current, passthrough_link: 'https://www.notebook.ai/my/data/green', - reference_code: 'green-trees' - ) unless user.notifications.where(reference_code: 'green-trees').any? + reference_code: reference_code + ) unless user.notifications.where(reference_code: reference_code).any? end end end From c0c559f1c4fb230b18308e6c872c57fb84ce2f44 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 29 Jul 2021 13:18:21 -0700 Subject: [PATCH 101/149] skip some heavy cachebuilding for doc update api calls --- app/controllers/documents_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 4ded2037..11409780 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -10,6 +10,10 @@ class DocumentsController < ApplicationController before_action :set_navbar_actions, except: [:edit, :plaintext] before_action :set_footer_visibility, only: [:edit] + # Skip UI-heavy calls for API endpoints + skip_before_action :cache_most_used_page_information, only: [:update] + skip_before_action :cache_forums_unread_counts, only: [:update] + # TODO: verify_user_can_read, verify_user_can_edit, etc before_actions instead of inlining them before_action :cache_linkable_content_for_each_content_type, only: [:edit] From 78bfb55d67a6670fb8b755d9abd5c0b2950ea323 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 16:44:16 -0700 Subject: [PATCH 102/149] cache linkable image lookups --- app/models/concerns/has_image_uploads.rb | 9 ++++++++- app/views/main/dashboard.html.erb | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/has_image_uploads.rb b/app/models/concerns/has_image_uploads.rb index a59df6d2..28b36c52 100644 --- a/app/models/concerns/has_image_uploads.rb +++ b/app/models/concerns/has_image_uploads.rb @@ -17,7 +17,14 @@ module HasImageUploads end def random_image_including_private(format: :medium) - image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg" + @cache ||= {} + key = self.class.name + self.id.to_s + return @cache[key] if @cache.key?(key) + + result = image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg" + @cache[key] = result + + result end def first_public_image(format: :medium) diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index b6b52bcc..fc9642b8 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -184,8 +184,10 @@ <% 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 %>
          From 055cdd17b010c1650eb3a7ef6396f986627077b4 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 16:44:31 -0700 Subject: [PATCH 103/149] show free-creatures banner --- app/views/main/dashboard.html.erb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index fc9642b8..73c5de64 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -209,6 +209,24 @@ <% end %>
          <% end %> + +
          +
          + <%= link_to new_creature_path, class: "white-text", style: 'width: 100%' do %> +
          +
          + <%= Creature.icon %> + + New Creature
          + + Free for all users in October + +
          +
          +
          + <% end %> +
          +
          From 3326b9affb623ef503fdae6920043f3a15c106aa Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 16:56:26 -0700 Subject: [PATCH 104/149] make creatures free in october --- app/models/page_types/creature.rb | 2 +- config/initializers/content_types.rb | 2 +- config/initializers/promos.rb | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/page_types/creature.rb b/app/models/page_types/creature.rb index 61925486..19ad5da3 100644 --- a/app/models/page_types/creature.rb +++ b/app/models/page_types/creature.rb @@ -20,7 +20,7 @@ class Creature < ApplicationRecord include Serendipitous::Concern include Authority::Abilities - self.authorizer_name = 'ExtendedContentAuthorizer' + self.authorizer_name = 'CoreContentAuthorizer' # Locations relates :habitats, with: :wildlifeships diff --git a/config/initializers/content_types.rb b/config/initializers/content_types.rb index 2644df09..30998968 100644 --- a/config/initializers/content_types.rb +++ b/config/initializers/content_types.rb @@ -66,7 +66,7 @@ Rails.application.config.content_types = { # Content types to label as "new" around the site new: [ - Lore + ] } diff --git a/config/initializers/promos.rb b/config/initializers/promos.rb index e58bd393..560d1547 100644 --- a/config/initializers/promos.rb +++ b/config/initializers/promos.rb @@ -6,7 +6,7 @@ Rails.application.config.promos[:promo_bogo] = {} Rails.application.config.promos[:promo_bogo][:start_date] = 'March 21, 2020'.to_date Rails.application.config.promos[:promo_bogo][:end_date] = Rails.application.config.promos[:promo_bogo][:start_date] + 2.weeks -# Lore free during the month of April +# Lore free during the month of April, 2020 # Need to change Lore.rb authorizer at the end lol if Date.current >= 'March 1, 2020'.to_date if Date.current < 'April 1, 2020'.to_date @@ -14,3 +14,12 @@ if Date.current >= 'March 1, 2020'.to_date Rails.application.config.content_types[:premium] -= [Lore] end end + +# Lore free during the month of October +# Need to change Creature.rb authorizer at the end +if Date.current >= 'October 1, 2021'.to_date + if Date.current < 'November 1, 2021'.to_date + Rails.application.config.content_types[:free] << Creature + Rails.application.config.content_types[:premium] -= [Creature] + end +end From 255a4979f7b579fb120acb1f0aa388aa222650fb Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 17:00:12 -0700 Subject: [PATCH 105/149] Safer cache name --- app/models/concerns/has_image_uploads.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/has_image_uploads.rb b/app/models/concerns/has_image_uploads.rb index 28b36c52..9327744a 100644 --- a/app/models/concerns/has_image_uploads.rb +++ b/app/models/concerns/has_image_uploads.rb @@ -17,12 +17,12 @@ module HasImageUploads end def random_image_including_private(format: :medium) - @cache ||= {} + @random_image_including_private_cache ||= {} key = self.class.name + self.id.to_s - return @cache[key] if @cache.key?(key) + return @random_image_including_private_cache[key] if @random_image_including_private_cache.key?(key) result = image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg" - @cache[key] = result + @random_image_including_private_cache[key] = result result end From 1720c841602ba025f266a50e73a341dbe1947002 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 17:19:17 -0700 Subject: [PATCH 106/149] nix a query --- app/services/permission_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/permission_service.rb b/app/services/permission_service.rb index 98244b22..bfc15d90 100644 --- a/app/services/permission_service.rb +++ b/app/services/permission_service.rb @@ -5,7 +5,7 @@ class PermissionService < Service end def self.user_owns_content?(user:, content:) - content.user && user && content.user.try(:id) == user.try(:id) + content.user && user && content.try(:user_id) == user.try(:id) end def self.user_owns_any_containing_universe?(user:, content:) From 6a208e30164bb02aceff16c7d6532a8a067fa44e Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 17:36:58 -0700 Subject: [PATCH 107/149] remove set_universe_scope dependence on current_user_content cache --- app/controllers/application_controller.rb | 31 +++++++++++++++++------ app/controllers/content_controller.rb | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4b053e95..175b9ba6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,13 +35,23 @@ class ApplicationController < ActionController::Base def set_universe_scope if user_signed_in? && session.key?(:universe_id) - cache_contributable_universe_ids - - if @contributable_universe_ids.include?(session[:universe_id]) - @universe_scope = Universe.find_by(id: session[:universe_id]) - else - @universe_scope = nil + @universe_scope = Universe.find_by(id: session[:universe_id]) + + if @universe_scope && @universe_scope.user_id != current_user.try(:id) + # Verify the current user has access to this universe by looking up their + # universe contributorship + contributorship = Contributor.find_by( + user: current_user, + universe: @universe_scope + ) + + if contributorship.nil? + # If the user doesn't have current contributor access to this universe, + # then revert back to unscoped universe actions + @universe_scope = nil + end end + else @universe_scope = nil end @@ -79,7 +89,10 @@ class ApplicationController < ActionController::Base cache_activated_content_types # We always want to cache Universes, even if they aren't explicitly turned on. - @current_user_content = current_user.content(content_types: @activated_content_types + [Universe.name], universe_id: @universe_scope.try(:id)) + @current_user_content = current_user.content( + content_types: @activated_content_types + [Universe.name], + universe_id: @universe_scope.try(:id) + ) # Likewise, we should also always cache Timelines & Documents if @universe_scope @@ -143,6 +156,8 @@ class ApplicationController < ActionController::Base end def cache_contributable_universe_ids + cache_current_user_content + @contributable_universe_ids ||= if user_signed_in? current_user.contributable_universe_ids + @current_user_content.fetch('Universe', []).map(&:id) else @@ -165,7 +180,7 @@ class ApplicationController < ActionController::Base # so all we need to grab is additional pages in contributable universes @linkables_raw[page_type] = @current_user_content[page_type] - if @contributable_universe_ids.any? + if !@universe_scope && @contributable_universe_ids.any? existing_page_ids = @linkables_raw[page_type].map(&:id) pages_to_add = if page_type == Universe.name diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 78f7942c..51b7f2b2 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -33,7 +33,7 @@ class ContentController < ApplicationController # Linkables cache is already scoped per-universe, includes contributor pages @content = @linkables_raw.fetch(@content_type_class.name, []) - @show_scope_notice = @universe_scope.present? && content_type_class != Universe + @show_scope_notice = @universe_scope.present? && @content_type_class != Universe # Filters @page_tags = PageTag.where( From 979ee7e261c144b9c6cfef0b822d2a19dec151a7 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 17:46:08 -0700 Subject: [PATCH 108/149] document universe filter banner redesign --- app/views/documents/index.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/documents/index.html.erb b/app/views/documents/index.html.erb index d89f01df..3992c228 100644 --- a/app/views/documents/index.html.erb +++ b/app/views/documents/index.html.erb @@ -1,11 +1,11 @@ <% if @universe_scope %> -

          +

          Only showing documents - in the <%= link_to @universe_scope.name, @universe_scope, class: Universe.color + '-text' %> universe. + in the <%= link_to @universe_scope.name, @universe_scope, class: Universe.text_color %> universe.  <%= link_to( - "See documents from all universes.", + "See documents from all universes instead.", '?universe=all', - class: Universe.color + '-text') + class: Universe.text_color) %>

          <% end %> From 5f8153cb967f533a41d9cde8ad833433d98f347e Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 17:51:57 -0700 Subject: [PATCH 109/149] touch timelines when timeline events are created to make sure updated_at sets properly --- app/models/timelines/timeline_event.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/timelines/timeline_event.rb b/app/models/timelines/timeline_event.rb index fc68f032..9cbe6c9e 100644 --- a/app/models/timelines/timeline_event.rb +++ b/app/models/timelines/timeline_event.rb @@ -1,7 +1,7 @@ class TimelineEvent < ApplicationRecord acts_as_paranoid - belongs_to :timeline + belongs_to :timeline, touch: true has_many :timeline_event_entities, dependent: :destroy From 1897e2a5112c50fdbbe48afdecdc686167a3e4b6 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 23:23:54 -0700 Subject: [PATCH 110/149] fix for logged-out users --- app/views/content/display/attribute_value/_link.html.erb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/content/display/attribute_value/_link.html.erb b/app/views/content/display/attribute_value/_link.html.erb index 28b5be08..94e62602 100644 --- a/app/views/content/display/attribute_value/_link.html.erb +++ b/app/views/content/display/attribute_value/_link.html.erb @@ -9,8 +9,12 @@ on js-load-page-name to fetch & load in post-page-load if the content isn't ours. %> <% - content = @current_user_content.fetch(klass, []).detect do |page| - page.page_type === klass && page.id === id.to_i + content = if user_signed_in? + @current_user_content.fetch(klass, []).detect do |page| + page.page_type === klass && page.id === id.to_i + end + else + nil end %> From 1db1813d80b15d6ca86ac24f4a80b2fc6f67cb63 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 30 Sep 2021 23:45:41 -0700 Subject: [PATCH 111/149] can't skip this before_action if it's not a before_action --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 175b9ba6..8d9c955e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base before_action :set_universe_scope before_action :cache_most_used_page_information + before_action :cache_forums_unread_counts before_action :set_metadata @@ -66,7 +67,6 @@ class ApplicationController < ActionController::Base cache_current_user_content cache_notifications cache_recently_edited_pages - cache_forums_unread_counts end def cache_activated_content_types From e46a491856f4b6660441abb91d6393d1662827e1 Mon Sep 17 00:00:00 2001 From: drusepth Date: Fri, 1 Oct 2021 00:06:59 -0700 Subject: [PATCH 112/149] auto-enable created page types --- app/controllers/content_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 51b7f2b2..521fee85 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -118,6 +118,10 @@ class ContentController < ApplicationController end @content.save! + + # If the user doesn't have this content type enabled, go ahead and automatically enable it for them + current_user.user_content_type_activators.find_or_create_by(content_type: @content.class.name) + return redirect_to edit_polymorphic_path(@content) else return redirect_to(subscription_path, notice: "#{@content.class.name.pluralize} require a Premium subscription to create.") @@ -186,6 +190,9 @@ class ContentController < ApplicationController end end + # If the user doesn't have this content type enabled, go ahead and automatically enable it for them + current_user.user_content_type_activators.find_or_create_by(content_type: content_type.name) + successful_response(content_creation_redirect_url, t(:create_success, model_name: @content.try(:name).presence || humanized_model_name)) else failed_response('new', :unprocessable_entity, "Unable to save page. Error code: " + @content.errors.to_json.to_s) From 8b868aa27dce962a14780ae8def0800899a33c97 Mon Sep 17 00:00:00 2001 From: drusepth Date: Fri, 1 Oct 2021 00:07:10 -0700 Subject: [PATCH 113/149] infer class from list objects --- app/views/content/list/_list.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/content/list/_list.html.erb b/app/views/content/list/_list.html.erb index 19d58121..27447b8f 100644 --- a/app/views/content/list/_list.html.erb +++ b/app/views/content/list/_list.html.erb @@ -58,10 +58,10 @@ <% content.page_tags.each do |tag| %> <% if user_signed_in? && content.user == current_user %> <%= link_to params.permit(:tag).merge({ tag: PageTagService.slug_for(tag.tag) }) do %> - + <% end %> <% else %> - + <% end %> <% end %> <% end %> From 4e9f20a1a8701323ad40242f6743a0de1f704142 Mon Sep 17 00:00:00 2001 From: drusepth Date: Fri, 1 Oct 2021 00:24:17 -0700 Subject: [PATCH 114/149] use asset pipeline for image fallbacks --- app/models/concerns/has_image_uploads.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/has_image_uploads.rb b/app/models/concerns/has_image_uploads.rb index 9327744a..392350eb 100644 --- a/app/models/concerns/has_image_uploads.rb +++ b/app/models/concerns/has_image_uploads.rb @@ -9,11 +9,11 @@ module HasImageUploads # todo: destroy from s3 on destroy def public_image_uploads - self.image_uploads.where(privacy: 'public').presence || ["card-headers/#{self.class.name.downcase.pluralize}.jpg"] + self.image_uploads.where(privacy: 'public').presence || [header_asset_for(self.class.name)] end def private_image_uploads - self.image.uploads.where(privacy: 'private').presence || ["card-headers/#{self.class.name.downcase.pluralize}.jpg"] + self.image.uploads.where(privacy: 'private').presence || [header_asset_for(self.class.name)] end def random_image_including_private(format: :medium) @@ -21,18 +21,22 @@ module HasImageUploads key = self.class.name + self.id.to_s return @random_image_including_private_cache[key] if @random_image_including_private_cache.key?(key) - result = image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg" + result = image_uploads.sample.try(:src, format).presence || header_asset_for(self.class.name) @random_image_including_private_cache[key] = result result end def first_public_image(format: :medium) - public_image_uploads.first.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg" + public_image_uploads.first.try(:src, format).presence || header_asset_for(self.class.name) end def random_public_image(format: :medium) - public_image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg" + public_image_uploads.sample.try(:src, format).presence || header_asset_for(self.class.name) + end + + def header_asset_for(class_name) + ActionController::Base.helpers.asset_path("card-headers/#{class_name.downcase.pluralize}.jpg") end end end From c544f2290bf30c06da30fd8f09115ce4ab6fac74 Mon Sep 17 00:00:00 2001 From: drusepth Date: Fri, 1 Oct 2021 00:44:47 -0700 Subject: [PATCH 115/149] use asset pipeline for other image fetches --- app/models/page_collections/page_collection.rb | 2 +- app/models/page_types/content_page.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/page_collections/page_collection.rb b/app/models/page_collections/page_collection.rb index 36e9e9a2..aa3d53a6 100644 --- a/app/models/page_collections/page_collection.rb +++ b/app/models/page_collections/page_collection.rb @@ -51,7 +51,7 @@ class PageCollection < ApplicationRecord end # If all else fails, fall back on default header - "card-headers/#{self.class.name.downcase.pluralize}.jpg" + ActionController::Base.helpers.asset_path("card-headers/#{self.class.name.downcase.pluralize}.jpg") end def first_public_image diff --git a/app/models/page_types/content_page.rb b/app/models/page_types/content_page.rb index c476d831..201b40f9 100644 --- a/app/models/page_types/content_page.rb +++ b/app/models/page_types/content_page.rb @@ -10,7 +10,7 @@ class ContentPage < ApplicationRecord self.authorizer_name = 'ContentPageAuthorizer' def random_image_including_private(format: :small) - ImageUpload.where(content_type: self.page_type, content_id: self.id).sample.try(:src, format) || "/assets/card-headers/#{self.page_type.downcase.pluralize}.jpg" + ImageUpload.where(content_type: self.page_type, content_id: self.id).sample.try(:src, format) || ActionController::Base.helpers.asset_path("card-headers/#{self.page_type.downcase.pluralize}.jpg") end def icon From e9a26eb12064b63dd9b03e3fb7f8b7922b87224a Mon Sep 17 00:00:00 2001 From: drusepth Date: Fri, 1 Oct 2021 00:59:19 -0700 Subject: [PATCH 116/149] fix filtering by tag --- app/controllers/content_controller.rb | 4 ++-- app/views/content/components/_list_filter_bar.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 521fee85..9b99761c 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -40,8 +40,8 @@ class ContentController < ApplicationController page_type: @content_type_class.name, page_id: @content.pluck(:id) ).order(:tag) - if params.key?(:tag) - @filtered_page_tags = @page_tags.where(slug: params[:tag]) + if params.key?(:slug) + @filtered_page_tags = @page_tags.where(slug: params[:slug]) @content.select! { |content| @filtered_page_tags.pluck(:page_id).include?(content.id) } end @page_tags = @page_tags.uniq(&:tag) diff --git a/app/views/content/components/_list_filter_bar.html.erb b/app/views/content/components/_list_filter_bar.html.erb index 94b68d40..955b2891 100644 --- a/app/views/content/components/_list_filter_bar.html.erb +++ b/app/views/content/components/_list_filter_bar.html.erb @@ -60,7 +60,7 @@
          \ No newline at end of file From 70126b487cdb60bff5361fe9e349d89600f31b7c Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 16:42:59 -0700 Subject: [PATCH 122/149] remove legacy links display & banner --- .../content/panels/_associations.html.erb | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/app/views/content/panels/_associations.html.erb b/app/views/content/panels/_associations.html.erb index d9b68636..3c2b17a6 100644 --- a/app/views/content/panels/_associations.html.erb +++ b/app/views/content/panels/_associations.html.erb @@ -2,10 +2,6 @@ TODO: everything here (probably) should move to the ContentSerializer so we don't have this heavy logic in a random partial %> -<% - relations = Rails.application.config.content_relations[content.class.name] - relations ||= [] -%>
          <%= render partial: 'notice_dismissal/messages/07' %> @@ -29,37 +25,5 @@ locals: { value: link_codes, content: content } %> <% end %> - - <% if user_signed_in? %> -
          - Notice: The newest Notebook.ai release is adding the ability to create your own link - fields, which includes a rather large migration of all existing link fields into a new linking system. - Links that haven't been migrated yet can be seen below this message; links on the new system appear above. -

          - Thank you for your patience during this large rewrite! This notice will automatically disappear after the - migration has completed for everyone. -

          - — Andrew -
          - <% end %> - - <%# TODO: remove these after finishing link migration script %> - <% relations.each do |name, params| %> - <% - results = params[:related_class].where("#{params[:through_relation].downcase}_id": content.id) - .map { |content| content.send(params[:inverse_class].downcase) } - .select { |content| content && content.readable_by?(current_user || User.new) } - %> - <% next unless results.any? %> - -
          - <%= params[:relation_text].to_s.titleize.downcase %> of -
          - <%= - link_codes = results.map { |page| "#{page.page_type}-#{page.id}" } - render partial: "content/display/attribute_value/link", - locals: { value: link_codes, content: content } - %> - <% end %>
          \ No newline at end of file From 06163e41d3d037edc0ebf5e9ca8db87ef95ca955 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 18:54:23 -0700 Subject: [PATCH 123/149] add exact date/time to changelog events --- app/views/content/display/_changelog.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/content/display/_changelog.html.erb b/app/views/content/display/_changelog.html.erb index 396aa2b0..b20af7a8 100644 --- a/app/views/content/display/_changelog.html.erb +++ b/app/views/content/display/_changelog.html.erb @@ -5,7 +5,6 @@ changed_fields = AttributeField.where(id: changed_attributes.pluck(:attribute_field_id)).includes([:attribute_category]) %> -

          @@ -72,7 +71,11 @@ <%= link_to(change_event.user.display_name, change_event.user, class: "#{User.text_color}") %> -
          <%= time_ago_in_words change_event.created_at %> ago
          +
          + <%= time_ago_in_words change_event.created_at %> ago + · + <%= change_event.created_at.strftime('%B %d, %H:%M %Z') %> +

          From 9674f597485921d8417811594cd3377ad5636040 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 18:54:37 -0700 Subject: [PATCH 124/149] improve changelog readability on dark mode --- app/views/content/display/_changelog.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/content/display/_changelog.html.erb b/app/views/content/display/_changelog.html.erb index b20af7a8..8f1aecee 100644 --- a/app/views/content/display/_changelog.html.erb +++ b/app/views/content/display/_changelog.html.erb @@ -78,7 +78,7 @@
        -
        +
        <%= render partial: "content/changelog/field_change/#{related_field.field_type}", locals: { old_value: old_value, new_value: new_value } From 0046af6880ccbb0ead8077e3d3e94fedbadb0323 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 21:23:58 -0700 Subject: [PATCH 125/149] add basic tags view in data vault --- app/assets/javascripts/content.js | 2 + app/controllers/data_controller.rb | 4 + app/views/data/tags.html.erb | 121 +++++++++++++++++++++++++++++ app/views/data/usage.html.erb | 2 +- config/routes.rb | 1 + 5 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 app/views/data/tags.html.erb diff --git a/app/assets/javascripts/content.js b/app/assets/javascripts/content.js index 6eac7528..a23b7c93 100644 --- a/app/assets/javascripts/content.js +++ b/app/assets/javascripts/content.js @@ -104,6 +104,8 @@ $(document).ready(function () { // Replace this element's content with the name of the page var tag = $(this); + // TODO: we should be caching this to reduce duplicate requests on the same page + $.get( '/api/internal/' + tag.data('klass') + '/' + tag.data('id') + '/name' ).done(function (response) { diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb index f42eef7e..b6897575 100644 --- a/app/controllers/data_controller.rb +++ b/app/controllers/data_controller.rb @@ -115,6 +115,10 @@ class DataController < ApplicationController @content = current_user.content end + def tags + @tags = current_user.page_tags + end + def discussions @topics = Thredded::Topic.where(user_id: current_user.id) @posts = Thredded::Post.where(user_id: current_user.id) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb new file mode 100644 index 00000000..f13c631d --- /dev/null +++ b/app/views/data/tags.html.erb @@ -0,0 +1,121 @@ +<% Rails.application.config.content_types[:all].each do |content_type| %> + <% + grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) + + next if grouped_tags.values.length == 0 + %> + +

        <%= content_type.name %> tags

        + <% grouped_tags.each do |tag, page_list| %> +
        +
        +
        +
        +
        +
        + <%= + link_to send( + "#{content_type.name.downcase.pluralize}_path", + slug: PageTagService.slug_for(tag) + ) do + %> + + <% end %> +
        +
        + <% page_list.each do |page_tag| %> +
        + <%= link_to send("#{page_tag.page_type.downcase}_path", page_tag.page_id) do %> + + + <%= content_type.icon %> + + + + <%= "Loading #{content_type.name} name...".html_safe %> + + <% end %> +
        + <% end %> +
        +
        + +
        +
        +
        +
        + <% end %> +<% end %> + + +<% @tags.group_by(&:page_type).each do |page_type, tags| %> +
        +
        +
        +
        +
        <%= page_type %> tags
        + + <% tags.each do |tag| %> +
        +
        + <%= + link_to send( + "#{tag.page_type.downcase.pluralize}_path", + slug: tag.slug + ) do + %> + + <% end %> + +
        +
        + +
        +
        + <% end %> + +
        +
        +
        +
        +<% end %> + + +
        +
        +
        +
        +
        Tags
        +
        + <% @tags.group_by(&:page_type).each do |page_type, tags| %> +
        +
        + <%= page_type %> Tags +
        +
        + +
        + <% tags.each do |tag| %> +
        +
        + <%= + link_to send( + "#{tag.page_type.downcase.pluralize}_path", + slug: tag.slug + ) do + %> + + <% end %> +
        +
        + +
        +
        + <% end %> +
        + <% end %> +
        +
        +
        +
        +
        \ No newline at end of file diff --git a/app/views/data/usage.html.erb b/app/views/data/usage.html.erb index 0082c62f..e76979cf 100644 --- a/app/views/data/usage.html.erb +++ b/app/views/data/usage.html.erb @@ -81,4 +81,4 @@
        -
        \ No newline at end of file +
      diff --git a/config/routes.rb b/config/routes.rb index 96b6af37..3a020121 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -133,6 +133,7 @@ Rails.application.routes.draw do scope '/data' do get '/', to: 'data#index', as: :data_vault get '/usage', to: 'data#usage' + get '/tags', to: 'data#tags' get '/recyclebin', to: 'data#recyclebin' get '/archive', to: 'data#archive' get '/documents', to: 'data#documents', as: :data_documents From 661ef32c055433377c4f2f6b8ee4883c14ddfc4a Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 21:39:13 -0700 Subject: [PATCH 126/149] restyle tags page --- app/views/data/tags.html.erb | 146 ++++++++++------------------------- 1 file changed, 41 insertions(+), 105 deletions(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index f13c631d..6e399d8b 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -1,121 +1,57 @@ -<% Rails.application.config.content_types[:all].each do |content_type| %> - <% - grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) +

      Your Notebook.ai tags

      +
        + <% Rails.application.config.content_types[:all].each do |content_type| %> + <% + grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) - next if grouped_tags.values.length == 0 - %> + next if grouped_tags.values.length == 0 + %> -

        <%= content_type.name %> tags

        - <% grouped_tags.each do |tag, page_list| %> -
        -
        -
        -
        -
        -
        - <%= - link_to send( - "#{content_type.name.downcase.pluralize}_path", - slug: PageTagService.slug_for(tag) - ) do - %> - - <% end %> -
        -
        - <% page_list.each do |page_tag| %> -
        - <%= link_to send("#{page_tag.page_type.downcase}_path", page_tag.page_id) do %> - - - <%= content_type.icon %> - - - - <%= "Loading #{content_type.name} name...".html_safe %> - - <% end %> -
        - <% end %> -
        -
        - -
        -
        +
      • +
        + <%= content_type.icon %> + <%= content_type.name %> tags + <%= grouped_tags.values.length %>
        -
      • - <% end %> -<% end %> - - -<% @tags.group_by(&:page_type).each do |page_type, tags| %> -
        -
        -
        -
        -
        <%= page_type %> tags
        - - <% tags.each do |tag| %> -
        -
        +
        + <% grouped_tags.each do |tag, page_list| %> +
        +
        +
        <%= link_to send( - "#{tag.page_type.downcase.pluralize}_path", - slug: tag.slug + "#{content_type.name.downcase.pluralize}_path", + slug: PageTagService.slug_for(tag) ) do %> - + + <%= tag %> + <% end %> -
        -
        - +
        + Used by <%= pluralize page_list.length, 'page' %>
        - <% end %> - -
        -
        -
        -
        -<% end %> - - -
        -
        -
        -
        -
        Tags
        -
        - <% @tags.group_by(&:page_type).each do |page_type, tags| %> -
        -
        - <%= page_type %> Tags -
        -
        -
        - <% tags.each do |tag| %> -
        -
        - <%= - link_to send( - "#{tag.page_type.downcase.pluralize}_path", - slug: tag.slug - ) do - %> - - <% end %> -
        -
        - -
        + <% page_list.each do |page_tag| %> +
        + <%= link_to send("#{page_tag.page_type.downcase}_path", page_tag.page_id) do %> + + + <%= content_type.icon %> + + + + Loading <%= content_type.name %> name... + + <% end %>
        <% end %>
        - <% end %> -
        +
        + <% end %>
        -
        -
        -
        \ No newline at end of file + + <% end %> +
      \ No newline at end of file From 6092fcc26c2bacce3ab76440518ee4b126b97841 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:31:14 -0700 Subject: [PATCH 127/149] add caching to js name lookups --- app/assets/javascripts/content.js | 36 ++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/content.js b/app/assets/javascripts/content.js index a23b7c93..b767b0e2 100644 --- a/app/assets/javascripts/content.js +++ b/app/assets/javascripts/content.js @@ -104,15 +104,35 @@ $(document).ready(function () { // Replace this element's content with the name of the page var tag = $(this); - // TODO: we should be caching this to reduce duplicate requests on the same page + // Instantiate a cache for all page lookup queries (if not already created) + window.load_page_name_cache ||= {}; + var page_name_key = tag.data('klass') + '/' + tag.data('id'); - $.get( - '/api/internal/' + tag.data('klass') + '/' + tag.data('id') + '/name' - ).done(function (response) { - tag.find('.name-container').text(response); - }).fail(function() { - tag.find('.name-conainer').text("Unknown " + tag.data('klass')); - }); + if (page_name_key in window.load_page_name_cache) { + // If we've already made a request for this klass+id, we can just insta-load the + // cached result instead of requesting it again. + tag.find('.name-container').text(window.load_page_name_cache[page_name_key]); + + } else { + // If we haven't made a request for this klass+id, look it up and cache it + $.get( + '/api/internal/' + page_name_key + '/name' + ).done(function (response) { + tag.find('.name-container').text(response); + window.load_page_name_cache[page_name_key] = response; + + // Go ahead and pre-fill all tags on the page for this klass+id, too + $('.js-load-page-name[data-klass=' + tag.data('klass') + '][data-id=' + tag.data('id') + ']') + .find('.name-container') + .text(response); + + }).fail(function() { + tag.find('.name-container').text("Unknown " + tag.data('klass')); + }); + } + + + }); }); From 80cbfd5a47af4c0676f8c1010253cbd04b51dd39 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:31:23 -0700 Subject: [PATCH 128/149] space tags out a bit more --- app/views/data/tags.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 6e399d8b..24eeb289 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -15,7 +15,7 @@
    <% grouped_tags.each do |tag, page_list| %> -
    +
    <%= From 3475a3b533712fc848aeb06e446fe463445a0d71 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:47:22 -0700 Subject: [PATCH 129/149] add page tag controller with remove method --- app/assets/javascripts/page_tags.coffee | 3 +++ app/controllers/page_tags_controller.rb | 4 ++++ app/helpers/page_tags_helper.rb | 2 ++ app/views/data/tags.html.erb | 12 +++++++++++- app/views/page_tags/remove.html.erb | 2 ++ config/routes.rb | 2 ++ test/controllers/page_tags_controller_test.rb | 9 +++++++++ 7 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/page_tags.coffee create mode 100644 app/controllers/page_tags_controller.rb create mode 100644 app/helpers/page_tags_helper.rb create mode 100644 app/views/page_tags/remove.html.erb create mode 100644 test/controllers/page_tags_controller_test.rb diff --git a/app/assets/javascripts/page_tags.coffee b/app/assets/javascripts/page_tags.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/page_tags.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/controllers/page_tags_controller.rb b/app/controllers/page_tags_controller.rb new file mode 100644 index 00000000..883d6b30 --- /dev/null +++ b/app/controllers/page_tags_controller.rb @@ -0,0 +1,4 @@ +class PageTagsController < ApplicationController + def remove + end +end diff --git a/app/helpers/page_tags_helper.rb b/app/helpers/page_tags_helper.rb new file mode 100644 index 00000000..96c4808b --- /dev/null +++ b/app/helpers/page_tags_helper.rb @@ -0,0 +1,2 @@ +module PageTagsHelper +end diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 24eeb289..255c5758 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -29,9 +29,19 @@ <% end %>
    -
    +
    Used by <%= pluralize page_list.length, 'page' %>
    +
    + <%= + link_to 'Delete this tag', tag_remove_path( + page_type: content_type.name, + slug: PageTagService.slug_for(tag) + ), data: { + confirm: "Are you sure? This will delete this tag and remove it from all pages." + } + %> +
    <% page_list.each do |page_tag| %> diff --git a/app/views/page_tags/remove.html.erb b/app/views/page_tags/remove.html.erb new file mode 100644 index 00000000..bad92c4f --- /dev/null +++ b/app/views/page_tags/remove.html.erb @@ -0,0 +1,2 @@ +

    PageTags#remove

    +

    Find me in app/views/page_tags/remove.html.erb

    diff --git a/config/routes.rb b/config/routes.rb index 3a020121..992907d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -98,6 +98,8 @@ Rails.application.routes.draw do get '/scratchpad', to: 'main#notes', as: :notes + get 'tag/remove' + # Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks resources :documents diff --git a/test/controllers/page_tags_controller_test.rb b/test/controllers/page_tags_controller_test.rb new file mode 100644 index 00000000..2f89a08a --- /dev/null +++ b/test/controllers/page_tags_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class PageTagsControllerTest < ActionDispatch::IntegrationTest + test "should get remove" do + get page_tags_remove_url + assert_response :success + end + +end From a5b1faecb63a0b27ceb8fc3e39a8d0662872276e Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:56:07 -0700 Subject: [PATCH 130/149] allow deleting tags / removing from all linked pages --- app/controllers/page_tags_controller.rb | 11 +++++++++++ config/routes.rb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/page_tags_controller.rb b/app/controllers/page_tags_controller.rb index 883d6b30..0be6008a 100644 --- a/app/controllers/page_tags_controller.rb +++ b/app/controllers/page_tags_controller.rb @@ -1,4 +1,15 @@ class PageTagsController < ApplicationController def remove + # Params + # {"page_type"=>"Location", "slug"=>"mountains", "controller"=>"page_tags", "action"=>"remove" + return unless params.key?(:page_type) && params.key?(:slug) + + PageTag.where( + page_type: params[:page_type], + slug: params[:slug], + user_id: current_user.id + ).destroy_all + + return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' end end diff --git a/config/routes.rb b/config/routes.rb index 992907d2..7f2963f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -98,7 +98,7 @@ Rails.application.routes.draw do get '/scratchpad', to: 'main#notes', as: :notes - get 'tag/remove' + get 'tag/remove', to: 'page_tags#remove' # Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks resources :documents From c6abc8087990fe2acd242e60a7affa92e49fa818 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 22:59:19 -0700 Subject: [PATCH 131/149] show banner for when no tags are shown --- app/views/data/tags.html.erb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 255c5758..133d5039 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -1,3 +1,7 @@ +<% + showed_any_tags = false +%> +

    Your Notebook.ai tags

      <% Rails.application.config.content_types[:all].each do |content_type| %> @@ -5,6 +9,8 @@ grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) next if grouped_tags.values.length == 0 + + showed_any_tags = true %>
    • @@ -39,7 +45,7 @@ slug: PageTagService.slug_for(tag) ), data: { confirm: "Are you sure? This will delete this tag and remove it from all pages." - } + }, class: 'red-text' %>
    @@ -64,4 +70,10 @@
    <% end %> - \ No newline at end of file + + +<% if !showed_any_tags %> +
    + When you create tags for your pages, they'll appear here. Come back later when you've added some! +
    +<% end %> \ No newline at end of file From d81641acc13da26257d84b667a67d304c8001c40 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 23:10:45 -0700 Subject: [PATCH 132/149] add tag management link to data vault --- app/views/data/index.html.erb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/views/data/index.html.erb b/app/views/data/index.html.erb index 5d291cce..88beecef 100644 --- a/app/views/data/index.html.erb +++ b/app/views/data/index.html.erb @@ -69,6 +69,20 @@ <% end %>
    +
    + <%= link_to tags_path, class: 'black-text' do %> +
    +
    + <%= PageTag.icon %> +
    Tag management
    +

    + Manage the tags you've used for your worldbuilding. +

    +
    +
    + <% end %> +
    +
    <%= link_to notebook_export_path, class: 'black-text' do %>
    From dd8b0bbe9aa1141e55d4d5e3456fb87198d91b14 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 23:18:37 -0700 Subject: [PATCH 133/149] sort tags alphabetically on tag page --- app/views/data/tags.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 133d5039..16dfcac2 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -6,7 +6,7 @@
      <% Rails.application.config.content_types[:all].each do |content_type| %> <% - grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).group_by(&:tag) + grouped_tags = PageTag.where(page_type: content_type.name, user_id: current_user).order('tag ASC').group_by(&:tag) next if grouped_tags.values.length == 0 From 822157fc1d8315ceb9978ff25669f25ab8aa27f2 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 23:35:47 -0700 Subject: [PATCH 134/149] remove unused view --- app/views/page_tags/remove.html.erb | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 app/views/page_tags/remove.html.erb diff --git a/app/views/page_tags/remove.html.erb b/app/views/page_tags/remove.html.erb deleted file mode 100644 index bad92c4f..00000000 --- a/app/views/page_tags/remove.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

      PageTags#remove

      -

      Find me in app/views/page_tags/remove.html.erb

      From 94bfb0f9b0ce99d7a564fe157686a9739950c5f5 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 4 Oct 2021 23:36:04 -0700 Subject: [PATCH 135/149] appease Uglifier for asset compilation --- app/assets/javascripts/content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/content.js b/app/assets/javascripts/content.js index b767b0e2..8de06125 100644 --- a/app/assets/javascripts/content.js +++ b/app/assets/javascripts/content.js @@ -105,7 +105,7 @@ $(document).ready(function () { var tag = $(this); // Instantiate a cache for all page lookup queries (if not already created) - window.load_page_name_cache ||= {}; + window.load_page_name_cache = window.load_page_name_cache || {}; var page_name_key = tag.data('klass') + '/' + tag.data('id'); if (page_name_key in window.load_page_name_cache) { From a243e18317e35eaf82cd068039970dadec7609bc Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 5 Oct 2021 00:22:45 -0700 Subject: [PATCH 136/149] add the ability to remove specific tags from tag management page --- app/controllers/page_tags_controller.rb | 8 ++++++++ app/views/data/tags.html.erb | 3 +++ config/routes.rb | 1 + 3 files changed, 12 insertions(+) diff --git a/app/controllers/page_tags_controller.rb b/app/controllers/page_tags_controller.rb index 0be6008a..250b2eee 100644 --- a/app/controllers/page_tags_controller.rb +++ b/app/controllers/page_tags_controller.rb @@ -1,4 +1,5 @@ class PageTagsController < ApplicationController + # Remove a tag and all of its links to a page def remove # Params # {"page_type"=>"Location", "slug"=>"mountains", "controller"=>"page_tags", "action"=>"remove" @@ -12,4 +13,11 @@ class PageTagsController < ApplicationController return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' end + + # Destroy a specific tag by ID + def destroy + PageTag.find_by(id: params[:id], user_id: current_user.id).destroy! + + return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' + end end diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 16dfcac2..4a6b672f 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -62,6 +62,9 @@ Loading <%= content_type.name %> name... <% end %> + <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag' } do %> + close + <% end %>
    <% end %>
    diff --git a/config/routes.rb b/config/routes.rb index 7f2963f0..f23865f2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -99,6 +99,7 @@ Rails.application.routes.draw do get '/scratchpad', to: 'main#notes', as: :notes get 'tag/remove', to: 'page_tags#remove' + delete 'tag/:id/destroy', to: 'page_tags#destroy', as: :destroy_specific_tag # Legacy route: left intact so /my/documents/X URLs continue to work for everyone's bookmarks resources :documents From 08e6ccc4455a03023654f1e300dc7cfd20c21d9d Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 5 Oct 2021 00:37:18 -0700 Subject: [PATCH 137/149] remote ajax call for removing tags --- app/controllers/page_tags_controller.rb | 4 ++-- app/views/data/tags.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/page_tags_controller.rb b/app/controllers/page_tags_controller.rb index 250b2eee..55653d39 100644 --- a/app/controllers/page_tags_controller.rb +++ b/app/controllers/page_tags_controller.rb @@ -11,13 +11,13 @@ class PageTagsController < ApplicationController user_id: current_user.id ).destroy_all - return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' + return redirect_back fallback_location: root_path, notice: 'Tag(s) deleted successfully.' end # Destroy a specific tag by ID def destroy PageTag.find_by(id: params[:id], user_id: current_user.id).destroy! - return redirect_back fallback_location: root_path, notice: 'Tag deleted successfully.' + return redirect_back fallback_location: root_path, notice: 'Tag(s) deleted successfully.' end end diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index 4a6b672f..e6b434e8 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -62,7 +62,7 @@ Loading <%= content_type.name %> name... <% end %> - <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag' } do %> + <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag' }, remote: true do %> close <% end %>
    From 32de29cff72596bfdfb08a96e589ccdea7347123 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 5 Oct 2021 00:48:21 -0700 Subject: [PATCH 138/149] verbiage --- app/views/data/tags.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/data/tags.html.erb b/app/views/data/tags.html.erb index e6b434e8..ee09258f 100644 --- a/app/views/data/tags.html.erb +++ b/app/views/data/tags.html.erb @@ -62,7 +62,7 @@ Loading <%= content_type.name %> name... <% end %> - <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag' }, remote: true do %> + <%= link_to destroy_specific_tag_path(page_tag), method: :delete, class: 'tooltipped', data: { tooltip: 'Remove this tag from this page' }, remote: true do %> close <% end %>
    From d5589cc2a6b0749009abae5030f82f8035662180 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 5 Oct 2021 01:28:39 -0700 Subject: [PATCH 139/149] destroy page tags when deleting pages --- app/models/concerns/has_page_tags.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/has_page_tags.rb b/app/models/concerns/has_page_tags.rb index b1ada5cb..cfcdb1eb 100644 --- a/app/models/concerns/has_page_tags.rb +++ b/app/models/concerns/has_page_tags.rb @@ -4,6 +4,6 @@ module HasPageTags extend ActiveSupport::Concern included do - has_many :page_tags, as: :page + has_many :page_tags, as: :page, dependent: :destroy end end From 5c61a3d5eaeea72a5b795d9622fb1ff2fb2a6e27 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 5 Oct 2021 01:28:53 -0700 Subject: [PATCH 140/149] add rake task for cleaning up orphaned page tags --- lib/tasks/one_off.rake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/tasks/one_off.rake b/lib/tasks/one_off.rake index fe94a703..bbd826c4 100644 --- a/lib/tasks/one_off.rake +++ b/lib/tasks/one_off.rake @@ -1,4 +1,15 @@ namespace :one_off do + desc "Clean up orphaned page tags" + task clean_orphaned_page_tags: :environment do + PageTag.find_each do |page_tag| + referenced_page = page_tag.page + + if page.nil? + page_tag.destroy + end + end + end + desc "Alert users who've saved at least one tree" task trees_notification: :environment do reference_code = 'green-trees' From 118b09febdfebed4b56156832b97d4ac2edc668e Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 7 Oct 2021 14:50:11 -0700 Subject: [PATCH 141/149] fix orphan fix --- lib/tasks/one_off.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/one_off.rake b/lib/tasks/one_off.rake index bbd826c4..aba9f648 100644 --- a/lib/tasks/one_off.rake +++ b/lib/tasks/one_off.rake @@ -4,7 +4,7 @@ namespace :one_off do PageTag.find_each do |page_tag| referenced_page = page_tag.page - if page.nil? + if referenced_page.nil? page_tag.destroy end end From c312d439994bae70f605d3c9af1f67d40a90a195 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 7 Oct 2021 15:57:16 -0700 Subject: [PATCH 142/149] add cached word count to attributes, backfill task --- app/jobs/cache_attribute_word_count_job.rb | 30 +++++++++++++++++++ app/models/page_data/attribute.rb | 4 +++ ...5520_add_word_count_cache_to_attributes.rb | 5 ++++ db/schema.rb | 3 +- lib/tasks/backfill.rake | 24 +++++++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 app/jobs/cache_attribute_word_count_job.rb create mode 100644 db/migrate/20211007215520_add_word_count_cache_to_attributes.rb diff --git a/app/jobs/cache_attribute_word_count_job.rb b/app/jobs/cache_attribute_word_count_job.rb new file mode 100644 index 00000000..fd1238dc --- /dev/null +++ b/app/jobs/cache_attribute_word_count_job.rb @@ -0,0 +1,30 @@ +class CacheAttributeWordCountJob < ApplicationJob + queue_as :cache + + def perform(*args) + attribute_id = args.shift + attribute = Attribute.find_by(id: attribute_id) + + return if attribute.nil? + return if attribute.value.nil? || attribute.value.blank? + + word_count = WordCountAnalyzer::Counter.new( + ellipsis: 'no_special_treatment', + hyperlink: 'count_as_one', + contraction: 'count_as_one', + hyphenated_word: 'count_as_one', + date: 'no_special_treatment', + number: 'count', + numbered_list: 'ignore', + xhtml: 'remove', + forward_slash: 'count_as_multiple_except_dates', + backslash: 'count_as_one', + dotted_line: 'ignore', + dashed_line: 'ignore', + underscore: 'ignore', + stray_punctuation: 'ignore' + ).count(attribute.value) + + attribute.update!(word_count_cache: word_count) + end +end diff --git a/app/models/page_data/attribute.rb b/app/models/page_data/attribute.rb index cdd17cb1..53bf6182 100644 --- a/app/models/page_data/attribute.rb +++ b/app/models/page_data/attribute.rb @@ -19,6 +19,10 @@ class Attribute < ApplicationRecord end end + after_commit do + CacheAttributeWordCountJob.perform_later(self.id) if saved_changes.key?('value') + end + after_save do entity.touch end diff --git a/db/migrate/20211007215520_add_word_count_cache_to_attributes.rb b/db/migrate/20211007215520_add_word_count_cache_to_attributes.rb new file mode 100644 index 00000000..f72faabd --- /dev/null +++ b/db/migrate/20211007215520_add_word_count_cache_to_attributes.rb @@ -0,0 +1,5 @@ +class AddWordCountCacheToAttributes < ActiveRecord::Migration[6.0] + def change + add_column :attributes, :word_count_cache, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 91d7d384..6f325752 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_15_030031) do +ActiveRecord::Schema.define(version: 2021_10_07_215520) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false @@ -165,6 +165,7 @@ ActiveRecord::Schema.define(version: 2021_09_15_030031) do t.datetime "created_at" t.datetime "updated_at" t.datetime "deleted_at" + t.integer "word_count_cache" t.index ["attribute_field_id", "deleted_at", "entity_id", "entity_type"], name: "attributes_afi_deleted_at_entity_id_entity_type" t.index ["attribute_field_id", "deleted_at"], name: "index_attributes_on_attribute_field_id_and_deleted_at" t.index ["attribute_field_id", "user_id", "entity_type", "entity_id", "deleted_at"], name: "attributes_afi_ui_et_ei_da" diff --git a/lib/tasks/backfill.rake b/lib/tasks/backfill.rake index 713ded00..4f27e383 100644 --- a/lib/tasks/backfill.rake +++ b/lib/tasks/backfill.rake @@ -1,4 +1,28 @@ namespace :backfill do + desc "Backfill cached word counts on all attributes" + task attribute_word_count_caches: :environment do + Attribute.where(cached_word_count: nil).find_each do |attribute| + word_count = WordCountAnalyzer::Counter.new( + ellipsis: 'no_special_treatment', + hyperlink: 'count_as_one', + contraction: 'count_as_one', + hyphenated_word: 'count_as_one', + date: 'no_special_treatment', + number: 'count', + numbered_list: 'ignore', + xhtml: 'remove', + forward_slash: 'count_as_multiple_except_dates', + backslash: 'count_as_one', + dotted_line: 'ignore', + dashed_line: 'ignore', + underscore: 'ignore', + stray_punctuation: 'ignore' + ).count(attribute.value) + + attribute.update_column(:word_count_cache, word_count) + end + end + desc "Backfill cached word counts on all documents" task document_word_count_caches: :environment do Document.where(cached_word_count: nil).where.not(body: [nil, ""]).find_each(batch_size: 500) do |document| From 3e0d2210c2b1fbec8c61142580a32a9b513bc05f Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 7 Oct 2021 17:03:44 -0700 Subject: [PATCH 143/149] cache aggregated word counts on worldbuilding pages --- .../cache_sum_attribute_word_count_job.rb | 19 +++++++++++++++++++ app/models/concerns/is_content_page.rb | 5 +++++ app/models/page_data/attribute.rb | 8 +++++++- app/models/word_count_update.rb | 4 ++++ ...0211007234707_create_word_count_updates.rb | 12 ++++++++++++ db/schema.rb | 15 ++++++++++++++- lib/tasks/backfill.rake | 2 +- test/fixtures/word_count_updates.yml | 15 +++++++++++++++ test/models/word_count_update_test.rb | 7 +++++++ 9 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 app/jobs/cache_sum_attribute_word_count_job.rb create mode 100644 app/models/word_count_update.rb create mode 100644 db/migrate/20211007234707_create_word_count_updates.rb create mode 100644 test/fixtures/word_count_updates.yml create mode 100644 test/models/word_count_update_test.rb diff --git a/app/jobs/cache_sum_attribute_word_count_job.rb b/app/jobs/cache_sum_attribute_word_count_job.rb new file mode 100644 index 00000000..e8d8ebd4 --- /dev/null +++ b/app/jobs/cache_sum_attribute_word_count_job.rb @@ -0,0 +1,19 @@ +class CacheSumAttributeWordCountJob < ApplicationJob + queue_as :cache + + def perform(*args) + entity_type = args.shift + entity_id = args.shift + + entity = entity_type.constantize.find_by(id: entity_id) + sum_attribute_word_count = Attribute.where(entity_type: entity_type, entity_id: entity_id).sum(:word_count_cache) + + update = entity.word_count_updates.find_or_initialize_by( + for_date: DateTime.current, + ) + update.word_count = sum_attribute_word_count + update.user_id ||= entity.user_id + + update.save! + end +end diff --git a/app/models/concerns/is_content_page.rb b/app/models/concerns/is_content_page.rb index ad0b69fd..718797a4 100644 --- a/app/models/concerns/is_content_page.rb +++ b/app/models/concerns/is_content_page.rb @@ -18,6 +18,11 @@ module IsContentPage has_many :timeline_events, through: :timeline_event_entities has_many :timelines, -> { distinct }, through: :timeline_events + has_many :word_count_updates, as: :entity, dependent: :destroy + def latest_word_count_cache + word_count_updates.order('for_date DESC').limit(1).first.try(:word_count) || 0 + end + scope :unarchived, -> { where(archived_at: nil) } def archive! update!(archived_at: DateTime.now) diff --git a/app/models/page_data/attribute.rb b/app/models/page_data/attribute.rb index 53bf6182..a08f3cc2 100644 --- a/app/models/page_data/attribute.rb +++ b/app/models/page_data/attribute.rb @@ -20,7 +20,13 @@ class Attribute < ApplicationRecord end after_commit do - CacheAttributeWordCountJob.perform_later(self.id) if saved_changes.key?('value') + if saved_changes.key?('value') + # Cache the updated word count on this attribute + CacheAttributeWordCountJob.perform_later(self.id) + + # Cache the updated word count on the page this attribute belongs to + CacheSumAttributeWordCountJob.perform_later(self.entity_type, self.entity_id) + end end after_save do diff --git a/app/models/word_count_update.rb b/app/models/word_count_update.rb new file mode 100644 index 00000000..1f26dccc --- /dev/null +++ b/app/models/word_count_update.rb @@ -0,0 +1,4 @@ +class WordCountUpdate < ApplicationRecord + belongs_to :user + belongs_to :entity, polymorphic: true +end diff --git a/db/migrate/20211007234707_create_word_count_updates.rb b/db/migrate/20211007234707_create_word_count_updates.rb new file mode 100644 index 00000000..2d1b84ee --- /dev/null +++ b/db/migrate/20211007234707_create_word_count_updates.rb @@ -0,0 +1,12 @@ +class CreateWordCountUpdates < ActiveRecord::Migration[6.0] + def change + create_table :word_count_updates do |t| + t.references :user, null: false, foreign_key: true + t.references :entity, polymorphic: true, null: false + t.integer :word_count + t.date :for_date + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f325752..f74e1526 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_10_07_215520) do +ActiveRecord::Schema.define(version: 2021_10_07_234707) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false @@ -3637,6 +3637,18 @@ ActiveRecord::Schema.define(version: 2021_10_07_215520) do t.integer "habitat_id" end + create_table "word_count_updates", force: :cascade do |t| + t.integer "user_id", null: false + t.string "entity_type", null: false + t.integer "entity_id", null: false + t.integer "word_count" + t.date "for_date" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["entity_type", "entity_id"], name: "index_word_count_updates_on_entity_type_and_entity_id" + t.index ["user_id"], name: "index_word_count_updates_on_user_id" + end + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "api_keys", "users" add_foreign_key "api_requests", "application_integrations" @@ -4048,4 +4060,5 @@ ActiveRecord::Schema.define(version: 2021_10_07_215520) do add_foreign_key "vehicles", "users" add_foreign_key "votes", "users" add_foreign_key "votes", "votables" + add_foreign_key "word_count_updates", "users" end diff --git a/lib/tasks/backfill.rake b/lib/tasks/backfill.rake index 4f27e383..f2ed3945 100644 --- a/lib/tasks/backfill.rake +++ b/lib/tasks/backfill.rake @@ -1,7 +1,7 @@ namespace :backfill do desc "Backfill cached word counts on all attributes" task attribute_word_count_caches: :environment do - Attribute.where(cached_word_count: nil).find_each do |attribute| + Attribute.where(word_count_cache: nil).where.not(value: ["", " ", ".", nil]).find_each do |attribute| word_count = WordCountAnalyzer::Counter.new( ellipsis: 'no_special_treatment', hyperlink: 'count_as_one', diff --git a/test/fixtures/word_count_updates.yml b/test/fixtures/word_count_updates.yml new file mode 100644 index 00000000..172493ff --- /dev/null +++ b/test/fixtures/word_count_updates.yml @@ -0,0 +1,15 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + user: one + entity: one + entity_type: Entity + word_count: 1 + for_date: 2021-10-07 + +two: + user: two + entity: two + entity_type: Entity + word_count: 1 + for_date: 2021-10-07 diff --git a/test/models/word_count_update_test.rb b/test/models/word_count_update_test.rb new file mode 100644 index 00000000..9f0e4d0b --- /dev/null +++ b/test/models/word_count_update_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WordCountUpdateTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From b087c42e57b1338a99e1c4e1c5bd7a343f8a8f57 Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 7 Oct 2021 18:38:32 -0700 Subject: [PATCH 144/149] don't error (and therefore retry) if someone deletes a doc getting rev-saved --- app/jobs/save_document_revision_job.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/jobs/save_document_revision_job.rb b/app/jobs/save_document_revision_job.rb index d52d737f..d88ba876 100644 --- a/app/jobs/save_document_revision_job.rb +++ b/app/jobs/save_document_revision_job.rb @@ -4,8 +4,8 @@ class SaveDocumentRevisionJob < ApplicationJob def perform(*args) document_id = args.shift - document = Document.find(document_id) - return unless document.present? + document = Document.find_by(id: document_id) + return unless document # Update cached word count for the document regardless of how often this is called new_word_count = document.computed_word_count From 72049a1fc82c3cbe3897f4d604e606f69ba84e6d Mon Sep 17 00:00:00 2001 From: drusepth Date: Thu, 7 Oct 2021 18:46:40 -0700 Subject: [PATCH 145/149] save document word count updates, too --- app/jobs/save_document_revision_job.rb | 8 ++++++++ app/models/documents/document.rb | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/app/jobs/save_document_revision_job.rb b/app/jobs/save_document_revision_job.rb index d88ba876..95fc4101 100644 --- a/app/jobs/save_document_revision_job.rb +++ b/app/jobs/save_document_revision_job.rb @@ -11,6 +11,14 @@ class SaveDocumentRevisionJob < ApplicationJob new_word_count = document.computed_word_count document.update(cached_word_count: new_word_count) + # Save a WordCountUpdate for this document for today + update = document.word_count_updates.find_or_initialize_by( + for_date: DateTime.current, + ) + update.word_count = new_word_count + update.user_id ||= document.user_id + update.save! + # Make sure we're only storing revisions at least every 5 min latest_revision = document.document_revisions.order('created_at DESC').limit(1).first if latest_revision.present? && latest_revision.created_at > 5.minutes.ago diff --git a/app/models/documents/document.rb b/app/models/documents/document.rb index a28e3eb8..cbbd1027 100644 --- a/app/models/documents/document.rb +++ b/app/models/documents/document.rb @@ -26,6 +26,12 @@ class Document < ApplicationRecord attr_accessor :tagged_text + # Duplicated from is_content_page since we don't include that here yet + has_many :word_count_updates, as: :entity, dependent: :destroy + def latest_word_count_cache + word_count_updates.order('for_date DESC').limit(1).first.try(:word_count) || 0 + end + KEYS_TO_TRIGGER_REVISION_ON_CHANGE = %w(title body synopsis notes_text) def self.color From 1d0c609cb07a32357d51f07f5887c97ee9d3058b Mon Sep 17 00:00:00 2001 From: drusepth Date: Sat, 9 Oct 2021 22:46:10 -0700 Subject: [PATCH 146/149] include the current user's shared universes in contributable universes cache --- app/models/users/user.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/users/user.rb b/app/models/users/user.rb index 9c7583af..9b761fc8 100644 --- a/app/models/users/user.rb +++ b/app/models/users/user.rb @@ -122,6 +122,9 @@ class User < ApplicationRecord def contributable_universe_ids # TODO: email confirmation needs to happen for data safety / privacy (only verified emails) @contributable_universe_ids ||= Contributor.where('email = ? OR user_id = ?', self.email, self.id).pluck(:universe_id) + @contributable_universe_ids += Contributor.where(universe_id: my_universe_ids).pluck(:universe_id) + + @contributable_universe_ids.uniq end # TODO: rename this to #{content_type}_shared_with_me From 877990bc15eebad6a6ac757845a5d11c628b3bbf Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 25 Oct 2021 21:05:40 -0700 Subject: [PATCH 147/149] pull in thredded 6.1 support --- Gemfile.lock | 174 +++++++++++++++++++++++++-------------------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ff4e7ef5..d29d4ec1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,13 +13,13 @@ GIT GIT remote: https://github.com/indentlabs/thredded.git - revision: b9a3976e310bb4eeb3f9a4b30d6c176d15a28ce1 + revision: 6ed40273e4696fc4f32013e4f2a101ff8658b960 branch: feature/report-posts specs: thredded (0.16.16) active_record_union (>= 1.3.0) autoprefixer-rails - db_text_search (~> 0.3.0) + db_text_search (~> 0.3.2) friendly_id html-pipeline htmlentities @@ -28,10 +28,10 @@ GIT kramdown (>= 2.0.0) kramdown-parser-gfm nokogiri - onebox (~> 1.8, >= 1.8.99) + onebox (>= 1.8.99) pundit (>= 1.1.0) rails (>= 4.2.10, != 6.0.0.rc2) - rb-gravatar + rails_gravatar rinku sanitize sassc-rails (>= 2.0.0) @@ -41,38 +41,40 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.0.3.4) - actionpack (= 6.0.3.4) + actioncable (6.1.4.1) + actionpack (= 6.1.4.1) + activesupport (= 6.1.4.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3.4) - actionpack (= 6.0.3.4) - activejob (= 6.0.3.4) - activerecord (= 6.0.3.4) - activestorage (= 6.0.3.4) - activesupport (= 6.0.3.4) + actionmailbox (6.1.4.1) + actionpack (= 6.1.4.1) + activejob (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) mail (>= 2.7.1) - actionmailer (6.0.3.4) - actionpack (= 6.0.3.4) - actionview (= 6.0.3.4) - activejob (= 6.0.3.4) + actionmailer (6.1.4.1) + actionpack (= 6.1.4.1) + actionview (= 6.1.4.1) + activejob (= 6.1.4.1) + activesupport (= 6.1.4.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3.4) - actionview (= 6.0.3.4) - activesupport (= 6.0.3.4) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.4.1) + actionview (= 6.1.4.1) + activesupport (= 6.1.4.1) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3.4) - actionpack (= 6.0.3.4) - activerecord (= 6.0.3.4) - activestorage (= 6.0.3.4) - activesupport (= 6.0.3.4) + actiontext (6.1.4.1) + actionpack (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) nokogiri (>= 1.8.5) - actionview (6.0.3.4) - activesupport (= 6.0.3.4) + actionview (6.1.4.1) + activesupport (= 6.1.4.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -81,37 +83,39 @@ GEM activerecord (>= 4.0) active_storage_validations (0.9.5) rails (>= 5.2.0) - activejob (6.0.3.4) - activesupport (= 6.0.3.4) + activejob (6.1.4.1) + activesupport (= 6.1.4.1) globalid (>= 0.3.6) - activemodel (6.0.3.4) - activesupport (= 6.0.3.4) + activemodel (6.1.4.1) + activesupport (= 6.1.4.1) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.0.3.4) - activemodel (= 6.0.3.4) - activesupport (= 6.0.3.4) - activestorage (6.0.3.4) - actionpack (= 6.0.3.4) - activejob (= 6.0.3.4) - activerecord (= 6.0.3.4) - marcel (~> 0.3.1) - activesupport (6.0.3.4) + activerecord (6.1.4.1) + activemodel (= 6.1.4.1) + activesupport (= 6.1.4.1) + activestorage (6.1.4.1) + actionpack (= 6.1.4.1) + activejob (= 6.1.4.1) + activerecord (= 6.1.4.1) + activesupport (= 6.1.4.1) + marcel (~> 1.0.0) + mini_mime (>= 1.1.0) + activesupport (6.1.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) acts_as_list (1.0.4) activerecord (>= 4.2) - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) authority (3.3.0) activesupport (>= 3.0.0) - autoprefixer-rails (9.8.4) - execjs + autoprefixer-rails (10.3.3.0) + execjs (~> 2) aws-eventstream (1.2.0) aws-partitions (1.503.0) aws-sdk (3.1.0) @@ -1288,7 +1292,7 @@ GEM database_cleaner-core (2.0.1) dateslices (0.0.4) rails (> 4) - db_text_search (0.3.1) + db_text_search (0.3.2) activerecord (>= 4.1.15, < 7.0) debug_inspector (1.0.0) devise (4.8.0) @@ -1303,7 +1307,7 @@ GEM engtagger (0.2.1) erubi (1.10.0) eventmachine (1.2.7) - execjs (2.7.0) + execjs (2.8.1) faraday (0.17.3) multipart-post (>= 1.2, < 3) faraday_middleware (0.14.0) @@ -1319,7 +1323,7 @@ GEM flamegraph (0.9.5) font-awesome-rails (4.7.0.7) railties (>= 3.2, < 7) - friendly_id (5.3.0) + friendly_id (5.4.2) activerecord (>= 4.0.0) globalid (0.5.2) activesupport (>= 5.0) @@ -1356,7 +1360,7 @@ GEM image_processing (1.12.1) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - inline_svg (1.7.1) + inline_svg (1.7.2) activesupport (>= 3.0) nokogiri (>= 1.6) jmespath (1.4.0) @@ -1394,8 +1398,7 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) + marcel (1.0.2) material_icons (2.2.1) railties (>= 3.2) medium-editor-rails (2.3.1) @@ -1411,7 +1414,7 @@ GEM nokogiri (~> 1) rake mini_magick (4.11.0) - mini_mime (1.1.0) + mini_mime (1.1.2) mini_portile2 (2.6.1) mini_racer (0.4.0) libv8-node (~> 15.14.0.0) @@ -1425,10 +1428,8 @@ GEM nokogiri (1.12.5) mini_portile2 (~> 2.6.1) racc (~> 1.4) - nokogumbo (2.0.2) - nokogiri (~> 1.8, >= 1.8.4) - onebox (1.9.29) - addressable (~> 2.7.0) + onebox (2.2.19) + addressable (~> 2.8.0) htmlentities (~> 4.3) multi_json (~> 1.11) mustache @@ -1459,9 +1460,9 @@ GEM nio4r (~> 2.0) puma-heroku (2.0.0) puma (>= 5.0, < 6.0) - pundit (2.1.0) + pundit (2.1.1) activesupport (>= 3.0.0) - racc (1.5.2) + racc (1.6.0) rack (2.2.3) rack-mini-profiler (2.3.3) rack (>= 1.2.0) @@ -1472,20 +1473,20 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.0.3.4) - actioncable (= 6.0.3.4) - actionmailbox (= 6.0.3.4) - actionmailer (= 6.0.3.4) - actionpack (= 6.0.3.4) - actiontext (= 6.0.3.4) - actionview (= 6.0.3.4) - activejob (= 6.0.3.4) - activemodel (= 6.0.3.4) - activerecord (= 6.0.3.4) - activestorage (= 6.0.3.4) - activesupport (= 6.0.3.4) - bundler (>= 1.3.0) - railties (= 6.0.3.4) + rails (6.1.4.1) + actioncable (= 6.1.4.1) + actionmailbox (= 6.1.4.1) + actionmailer (= 6.1.4.1) + actionpack (= 6.1.4.1) + actiontext (= 6.1.4.1) + actionview (= 6.1.4.1) + activejob (= 6.1.4.1) + activemodel (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) + bundler (>= 1.15.0) + railties (= 6.1.4.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -1508,15 +1509,16 @@ GEM rails (>= 5.0, < 7) remotipart (~> 1.3) sassc-rails (>= 1.3, < 3) - railties (6.0.3.4) - actionpack (= 6.0.3.4) - activesupport (= 6.0.3.4) + rails_gravatar (1.0.4) + actionview + railties (6.1.4.1) + actionpack (= 6.1.4.1) + activesupport (= 6.1.4.1) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + rake (>= 0.13) + thor (~> 1.0) rake (13.0.6) rb-fsevent (0.11.0) - rb-gravatar (1.0.5) rb-inotify (0.10.1) ffi (~> 1.0) react-rails (2.6.1) @@ -1537,10 +1539,9 @@ GEM ruby-vips (2.0.17) ffi (~> 1.9) rubyzip (2.0.0) - sanitize (5.2.1) + sanitize (6.0.0) crass (~> 1.0.2) - nokogiri (>= 1.8.0) - nokogumbo (~> 2.0) + nokogiri (>= 1.12.0) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) sassc (2.4.0) @@ -1590,12 +1591,11 @@ GEM textstat (0.1.6) text-hyphen (~> 1.4, >= 1.4.1) thor (1.1.0) - thread_safe (0.3.6) tilt (2.0.10) timeago_js (3.0.2.2) tribute (3.6.0.0) - tzinfo (1.2.9) - thread_safe (~> 0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) @@ -1619,7 +1619,7 @@ GEM websocket-extensions (0.1.5) word_count_analyzer (1.0.1) engtagger - zeitwerk (2.4.2) + zeitwerk (2.5.1) PLATFORMS ruby From af9b47839ef26a6ebc4eb3386017c19a9759ce71 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 25 Oct 2021 21:06:07 -0700 Subject: [PATCH 148/149] safety on job --- app/jobs/cache_sum_attribute_word_count_job.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/jobs/cache_sum_attribute_word_count_job.rb b/app/jobs/cache_sum_attribute_word_count_job.rb index e8d8ebd4..63dad69a 100644 --- a/app/jobs/cache_sum_attribute_word_count_job.rb +++ b/app/jobs/cache_sum_attribute_word_count_job.rb @@ -6,8 +6,9 @@ class CacheSumAttributeWordCountJob < ApplicationJob entity_id = args.shift entity = entity_type.constantize.find_by(id: entity_id) - sum_attribute_word_count = Attribute.where(entity_type: entity_type, entity_id: entity_id).sum(:word_count_cache) + return if entity.nil? + sum_attribute_word_count = Attribute.where(entity_type: entity_type, entity_id: entity_id).sum(:word_count_cache) update = entity.word_count_updates.find_or_initialize_by( for_date: DateTime.current, ) From 89cf300b51debec7d9e9c010f9a22551c8f9660b Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 25 Oct 2021 21:06:19 -0700 Subject: [PATCH 149/149] add helpful cache rake task --- lib/tasks/backfill.rake | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/tasks/backfill.rake b/lib/tasks/backfill.rake index f2ed3945..bd36c8ed 100644 --- a/lib/tasks/backfill.rake +++ b/lib/tasks/backfill.rake @@ -23,6 +23,36 @@ namespace :backfill do end end + task :most_used_attribute_word_counts: :environment do + word_counts = {} + Attribute.where(word_count_cache: nil).group(:value).order('count_id DESC').limit(500).count(:id).each do |value, count| + word_count = WordCountAnalyzer::Counter.new( + ellipsis: 'no_special_treatment', + hyperlink: 'count_as_one', + contraction: 'count_as_one', + hyphenated_word: 'count_as_one', + date: 'no_special_treatment', + number: 'count', + numbered_list: 'ignore', + xhtml: 'remove', + forward_slash: 'count_as_multiple_except_dates', + backslash: 'count_as_one', + dotted_line: 'ignore', + dashed_line: 'ignore', + underscore: 'ignore', + stray_punctuation: 'ignore' + ).count(value) + + word_counts[word_count] ||= [] + word_counts[word_count].push value + puts "#{value} x #{count}: #{word_count} words" + end + + word_counts.each do |count, values| + Attribute.where(word_count_cache: nil, value: values).update_all(word_count_cache: count) + end + end + desc "Backfill cached word counts on all documents" task document_word_count_caches: :environment do Document.where(cached_word_count: nil).where.not(body: [nil, ""]).find_each(batch_size: 500) do |document|