From e1437336a6bb57431399b7d9d136919e6bdddf91 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 23 Aug 2019 23:03:01 -0500 Subject: [PATCH 01/12] only do docs query on sidelinks for #edit --- app/views/content/display/_sidelinks.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/content/display/_sidelinks.html.erb b/app/views/content/display/_sidelinks.html.erb index 4085f1ea..b3580a89 100644 --- a/app/views/content/display/_sidelinks.html.erb +++ b/app/views/content/display/_sidelinks.html.erb @@ -56,7 +56,7 @@ <% end %> - <% if content.documents.select { |doc| (current_user || User.new).can_read?(doc) }.any? %> + <% if editing && content.documents.select { |doc| (current_user || User.new).can_read?(doc) }.any? %>
  • <%= Document.icon %> From a22188c65b13afd1d68641b4f4a0b6e258fff6d5 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 23 Aug 2019 23:41:20 -0500 Subject: [PATCH 02/12] new db migrations --- ...190824040322_add_document_analysis_indices.rb | 16 ++++++++++++++++ db/schema.rb | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190824040322_add_document_analysis_indices.rb diff --git a/db/migrate/20190824040322_add_document_analysis_indices.rb b/db/migrate/20190824040322_add_document_analysis_indices.rb new file mode 100644 index 00000000..05ac942d --- /dev/null +++ b/db/migrate/20190824040322_add_document_analysis_indices.rb @@ -0,0 +1,16 @@ +class AddDocumentAnalysisIndices < ActiveRecord::Migration[5.2] + def change + add_index :documents, [:universe_id, :deleted_at] + + add_index :attribute_categories, [:entity_type, :name, :user_id] + + add_index :attribute_fields, [:attribute_category_id, :old_column_source, :user_id, :field_type], name: :attribute_fields_aci_ocs_ui_ft + + add_index :attributes, [:user_id, :deleted_at] + add_index :attributes, [:attribute_field_id, :user_id, :entity_type, :entity_id, :deleted_at], name: :attributes_afi_ui_et_ei_da + + add_index :motherships, [:mother_id, :character_id, :deleted_at] + add_index :fatherships, [:father_id, :character_id, :deleted_at] + #todo honestly we should probably do indices for all these triplet pairs (for each grouper) + end +end diff --git a/db/schema.rb b/db/schema.rb index f62e0e9e..ff12c95e 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: 2019_08_13_220011) do +ActiveRecord::Schema.define(version: 2019_08_24_040322) do create_table "api_keys", force: :cascade do |t| t.integer "user_id" @@ -46,6 +46,7 @@ ActiveRecord::Schema.define(version: 2019_08_13_220011) do t.boolean "hidden" t.datetime "deleted_at" t.integer "position" + t.index ["entity_type", "name", "user_id"], name: "index_attribute_categories_on_entity_type_and_name_and_user_id" t.index ["entity_type"], name: "index_attribute_categories_on_entity_type" t.index ["name"], name: "index_attribute_categories_on_name" t.index ["user_id"], name: "index_attribute_categories_on_user_id" @@ -68,6 +69,7 @@ ActiveRecord::Schema.define(version: 2019_08_13_220011) do t.index ["attribute_category_id", "deleted_at"], name: "index_attribute_fields_on_attribute_category_id_and_deleted_at" t.index ["attribute_category_id", "label", "old_column_source", "field_type"], name: "attribute_fields_aci_label_ocs_ft" t.index ["attribute_category_id", "label", "old_column_source", "user_id", "field_type"], name: "attribute_fields_aci_label_ocs_ui_ft" + t.index ["attribute_category_id", "old_column_source", "user_id", "field_type"], name: "attribute_fields_aci_ocs_ui_ft" t.index ["deleted_at", "attribute_category_id"], name: "deleted_at__attribute_category_id" t.index ["deleted_at", "name"], name: "index_attribute_fields_on_deleted_at_and_name" t.index ["deleted_at", "user_id", "attribute_category_id", "label", "hidden"], name: "attribute_fields_da_ui_aci_l_h" @@ -94,9 +96,11 @@ ActiveRecord::Schema.define(version: 2019_08_13_220011) do t.datetime "deleted_at" 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" t.index ["deleted_at", "attribute_field_id", "entity_type", "entity_id"], name: "deleted_at__attribute_field_id__entity_type_and_id" t.index ["entity_type", "entity_id"], name: "index_attributes_on_entity_type_and_entity_id" t.index ["user_id", "attribute_field_id"], name: "index_attributes_on_user_id_and_attribute_field_id" + t.index ["user_id", "deleted_at"], name: "index_attributes_on_user_id_and_deleted_at" t.index ["user_id", "entity_type", "entity_id"], name: "index_attributes_on_user_id_and_entity_type_and_entity_id" t.index ["user_id"], name: "index_attributes_on_user_id" end @@ -853,6 +857,7 @@ ActiveRecord::Schema.define(version: 2019_08_13_220011) do t.text "synopsis" t.datetime "deleted_at" t.integer "universe_id" + t.index ["universe_id", "deleted_at"], name: "index_documents_on_universe_id_and_deleted_at" t.index ["universe_id"], name: "index_documents_on_universe_id" t.index ["user_id"], name: "index_documents_on_user_id" end @@ -869,6 +874,7 @@ ActiveRecord::Schema.define(version: 2019_08_13_220011) do t.integer "father_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["father_id", "character_id", nil], name: "index_fatherships_on_father_id_and_character_id_and_deleted_at" end create_table "flora_eaten_bies", force: :cascade do |t| @@ -1507,6 +1513,7 @@ ActiveRecord::Schema.define(version: 2019_08_13_220011) do t.integer "mother_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["mother_id", "character_id", nil], name: "index_motherships_on_mother_id_and_character_id_and_deleted_at" end create_table "notable_cities_relationships", force: :cascade do |t| From 349a6c26ac231ca8e6b3b25f804efbb34369b075 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 23 Aug 2019 23:43:06 -0500 Subject: [PATCH 03/12] right-align template customization links --- app/controllers/content_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 48dd0508..7886be06 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -538,6 +538,7 @@ class ContentController < ApplicationController @navbar_actions << { label: 'Customize template', + class: 'right', href: main_app.attribute_customization_path(content_type.name.downcase) } end From d4d01f0a46f2e56f6714bfd92c2d04aaac50d842 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 23 Aug 2019 23:44:45 -0500 Subject: [PATCH 04/12] don't 500 (and potentially retry) if someone deletes their doc before analysis runs --- app/jobs/document_mention_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/document_mention_job.rb b/app/jobs/document_mention_job.rb index 94b141a7..0be41122 100644 --- a/app/jobs/document_mention_job.rb +++ b/app/jobs/document_mention_job.rb @@ -6,7 +6,7 @@ class DocumentMentionJob < ApplicationJob def perform(*args) document_id = args.shift - document = Document.find(document_id) + document = Document.find_by(id: document_id) return unless document.present? return if document.body.nil? || document.body.empty? From 94f4f7e5d6f89c9920a564714499507646e6c5f1 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 24 Aug 2019 11:15:07 -0500 Subject: [PATCH 05/12] first pass on sortable orderings backfill --- app/controllers/content_controller.rb | 18 ++++---- app/models/page_data/attribute_category.rb | 44 ++++++++++++++++++++ app/models/serializers/content_serializer.rb | 25 +++++------ lib/tasks/backfill.rake | 26 ++++++++++++ 4 files changed, 90 insertions(+), 23 deletions(-) create mode 100644 lib/tasks/backfill.rake diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 7886be06..797aa811 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -358,21 +358,17 @@ class ContentController < ApplicationController # Ugh not another one of these backfills if content.position.nil? - content_to_order_first = if content.is_a?(AttributeCategory) - content_type_class = content.entity_type.titleize.constantize - content_type_class.attribute_categories(current_user, show_hidden: true) + if content.is_a?(AttributeCategory) + content.backfill_categories_ordering! elsif content.is_a?(AttributeField) - content.attribute_category.attribute_fields - end - - ActiveRecord::Base.transaction do - content_to_order_first.each.with_index do |content_to_order, index| - content_to_order.update_column(:position, 1 + index) - end + content.attribute_category.backfill_fields_ordering! + else + raise "Attempting to backfill ordering for a new class: #{content.class.name}" end end - if content.reload && content.insert_at(1 + sort_params[:intended_position].to_i) + content.reload + if content.insert_at(1 + sort_params[:intended_position].to_i) render json: 200 else render json: 500 diff --git a/app/models/page_data/attribute_category.rb b/app/models/page_data/attribute_category.rb index b2154ba4..5f7895d9 100644 --- a/app/models/page_data/attribute_category.rb +++ b/app/models/page_data/attribute_category.rb @@ -45,4 +45,48 @@ class AttributeCategory < ApplicationRecord def ensure_name self.name ||= "#{label}-#{Time.now.to_i}".underscore.gsub(' ', '_') end + + def backfill_categories_ordering! + content_type_class = entity_type.titleize.constantize + category_owner = User.find(user_id) + + categories = content_type_class.attribute_categories(category_owner, show_hidden: true) + + ActiveRecord::Base.transaction do + categories.each.with_index do |content_to_order, index| + content_to_order.update_column(:position, 1 + index) + + # While we're doing this, we might as well backfill the fields also + content_to_order.backfill_fields_ordering! + end + end + end + + def backfill_fields_ordering! + sorted_fields = attribute_fields.sort do |a, b| + a_value = case a.field_type + when 'name' then 0 + when 'universe' then 1 + else 2 # 'text_area', 'link' + end + + b_value = case b.field_type + when 'name' then 0 + when 'universe' then 1 + else 2 + end + + if a.position && b.position + a.position <=> b.position + else + a_value <=> b_value + end + end + + ActiveRecord::Base.transaction do + sorted_fields.each.with_index do |content_to_order, index| + content_to_order.update_column(:position, 1 + index) + end + end + end end diff --git a/app/models/serializers/content_serializer.rb b/app/models/serializers/content_serializer.rb index 2fc821fd..6ed8ad76 100644 --- a/app/models/serializers/content_serializer.rb +++ b/app/models/serializers/content_serializer.rb @@ -68,18 +68,6 @@ class ContentSerializer value: value_for(field, content) } }.sort do |a, b| - a_value = case a[:type] - when 'name' then 0 - when 'universe' then 1 - else 2 # 'text_area', 'link' - end - - b_value = case b[:type] - when 'name' then 0 - when 'universe' then 1 - else 2 - end - # if a_value != b_value # a_value <=> b_value # else @@ -88,7 +76,20 @@ class ContentSerializer if a[:position] && b[:position] a[:position] <=> b[:position] + else + a_value = case a[:type] + when 'name' then 0 + when 'universe' then 1 + else 2 # 'text_area', 'link' + end + + b_value = case b[:type] + when 'name' then 0 + when 'universe' then 1 + else 2 + end + a_value <=> b_value end end diff --git a/lib/tasks/backfill.rake b/lib/tasks/backfill.rake new file mode 100644 index 00000000..dd5b3f4a --- /dev/null +++ b/lib/tasks/backfill.rake @@ -0,0 +1,26 @@ +namespace :backfill do + desc "Start working through old categories/fields without position set" + task sortables_positions: :environment do + categories_to_position = AttributeCategory.where(position: nil).to_a + fields_to_position = AttributeField.where(position: nil).to_a + + puts "Empty position backlog:\n\t- #{categories_to_position.count} categories\n\t- #{fields_to_position.count} fields" + + while categories_to_position.any? + category = categories_to_position.pop + + # Backfill all the positioning for this category's page's categories + category.backfill_categories_ordering! + + # We can skip this if we're just backfilling with a single worker, + # but in case we're backfilling on multiple this fetches a recent + # copy of updates before proceeding. Technically still a possibility + # of Doing The Same Thing Twice, but a smaller possibility. + categories_to_position = AttributeCategory.where(position: nil).to_a + + if rand(100) < 20 + puts "Empty position backlog:\n\t-#{categories_to_position.count} categories\n\t-#{fields_to_position.count} fields" + end + end + end +end From c5c6784bd5bc2b5381f096edf4a5d4bbc05abb51 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 24 Aug 2019 11:29:14 -0500 Subject: [PATCH 06/12] Done! --- lib/tasks/backfill.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tasks/backfill.rake b/lib/tasks/backfill.rake index dd5b3f4a..5e601b34 100644 --- a/lib/tasks/backfill.rake +++ b/lib/tasks/backfill.rake @@ -22,5 +22,7 @@ namespace :backfill do puts "Empty position backlog:\n\t-#{categories_to_position.count} categories\n\t-#{fields_to_position.count} fields" end end + + puts "Done!" end end From eac5d09786728842c8fe65e32ee408dc01171889 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 7 Sep 2019 20:58:53 -0500 Subject: [PATCH 07/12] add birthday column to users --- db/migrate/20190908015515_add_birthday_to_users.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190908015515_add_birthday_to_users.rb diff --git a/db/migrate/20190908015515_add_birthday_to_users.rb b/db/migrate/20190908015515_add_birthday_to_users.rb new file mode 100644 index 00000000..0a0ba634 --- /dev/null +++ b/db/migrate/20190908015515_add_birthday_to_users.rb @@ -0,0 +1,5 @@ +class AddBirthdayToUsers < ActiveRecord::Migration[5.2] + def change + add_column :users, :birthday, :date + end +end diff --git a/db/schema.rb b/db/schema.rb index c8dfb76a..1fc6de40 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: 2019_08_29_222650) do +ActiveRecord::Schema.define(version: 2019_09_08_015515) do create_table "api_keys", force: :cascade do |t| t.integer "user_id" @@ -2566,6 +2566,7 @@ ActiveRecord::Schema.define(version: 2019_08_29_222650) do t.string "interests" t.string "forums_badge_text" t.boolean "keyboard_shortcuts_preference" + t.date "birthday" t.index ["deleted_at", "username"], name: "index_users_on_deleted_at_and_username" t.index ["deleted_at"], name: "index_users_on_deleted_at" t.index ["email"], name: "index_users_on_email", unique: true From 01d93551d7045d4fa4c01f832f995fe2dae12de7 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 7 Sep 2019 21:03:13 -0500 Subject: [PATCH 08/12] Revert "add birthday column to users" This reverts commit eac5d09786728842c8fe65e32ee408dc01171889. --- db/migrate/20190908015515_add_birthday_to_users.rb | 5 ----- db/schema.rb | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 db/migrate/20190908015515_add_birthday_to_users.rb diff --git a/db/migrate/20190908015515_add_birthday_to_users.rb b/db/migrate/20190908015515_add_birthday_to_users.rb deleted file mode 100644 index 0a0ba634..00000000 --- a/db/migrate/20190908015515_add_birthday_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBirthdayToUsers < ActiveRecord::Migration[5.2] - def change - add_column :users, :birthday, :date - end -end diff --git a/db/schema.rb b/db/schema.rb index 1fc6de40..c8dfb76a 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: 2019_09_08_015515) do +ActiveRecord::Schema.define(version: 2019_08_29_222650) do create_table "api_keys", force: :cascade do |t| t.integer "user_id" @@ -2566,7 +2566,6 @@ ActiveRecord::Schema.define(version: 2019_09_08_015515) do t.string "interests" t.string "forums_badge_text" t.boolean "keyboard_shortcuts_preference" - t.date "birthday" t.index ["deleted_at", "username"], name: "index_users_on_deleted_at_and_username" t.index ["deleted_at"], name: "index_users_on_deleted_at" t.index ["email"], name: "index_users_on_email", unique: true From 40f9d59ee38c4cc59b65bf0bf9abe7425883dbb2 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 7 Sep 2019 21:11:58 -0500 Subject: [PATCH 09/12] uh, db conflict --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index c8dfb76a..9453d210 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: 2019_08_29_222650) do +ActiveRecord::Schema.define(version: 2019_09_08_015515) do create_table "api_keys", force: :cascade do |t| t.integer "user_id" From cdbf9130bad2ea635979f91c7d4652f4bb401b47 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 7 Sep 2019 21:20:39 -0500 Subject: [PATCH 10/12] who let this past qa --- db/migrate/20190824040322_add_document_analysis_indices.rb | 4 ---- db/schema.rb | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/db/migrate/20190824040322_add_document_analysis_indices.rb b/db/migrate/20190824040322_add_document_analysis_indices.rb index 05ac942d..4c06d517 100644 --- a/db/migrate/20190824040322_add_document_analysis_indices.rb +++ b/db/migrate/20190824040322_add_document_analysis_indices.rb @@ -8,9 +8,5 @@ class AddDocumentAnalysisIndices < ActiveRecord::Migration[5.2] add_index :attributes, [:user_id, :deleted_at] add_index :attributes, [:attribute_field_id, :user_id, :entity_type, :entity_id, :deleted_at], name: :attributes_afi_ui_et_ei_da - - add_index :motherships, [:mother_id, :character_id, :deleted_at] - add_index :fatherships, [:father_id, :character_id, :deleted_at] - #todo honestly we should probably do indices for all these triplet pairs (for each grouper) end end diff --git a/db/schema.rb b/db/schema.rb index 9453d210..d5780f17 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -874,7 +874,6 @@ ActiveRecord::Schema.define(version: 2019_09_08_015515) do t.integer "father_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["father_id", "character_id", nil], name: "index_fatherships_on_father_id_and_character_id_and_deleted_at" end create_table "flora_eaten_bies", force: :cascade do |t| @@ -1513,7 +1512,6 @@ ActiveRecord::Schema.define(version: 2019_09_08_015515) do t.integer "mother_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["mother_id", "character_id", nil], name: "index_motherships_on_mother_id_and_character_id_and_deleted_at" end create_table "notable_cities_relationships", force: :cascade do |t| @@ -2566,6 +2564,7 @@ ActiveRecord::Schema.define(version: 2019_09_08_015515) do t.string "interests" t.string "forums_badge_text" t.boolean "keyboard_shortcuts_preference" + t.date "birthday" t.index ["deleted_at", "username"], name: "index_users_on_deleted_at_and_username" t.index ["deleted_at"], name: "index_users_on_deleted_at" t.index ["email"], name: "index_users_on_email", unique: true From bd77eefb6f96a0509e4a62eddf082e5bfe38024c Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 7 Sep 2019 22:17:05 -0500 Subject: [PATCH 11/12] make backfills/position public --- app/models/concerns/has_attributes.rb | 6 +++--- app/models/page_data/attribute_category.rb | 12 ++++++------ app/views/content/attributes.html.erb | 5 ++++- db/schema.rb | 2 ++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/models/concerns/has_attributes.rb b/app/models/concerns/has_attributes.rb index 46dac36b..17652691 100644 --- a/app/models/concerns/has_attributes.rb +++ b/app/models/concerns/has_attributes.rb @@ -177,7 +177,7 @@ module HasAttributes ).pluck(:id) # Todo these two queries should be able to be joined into one - name_field = AttributeField.find_by( + AttributeField.find_by( user_id: user_id, attribute_category_id: category_ids, field_type: 'name' @@ -191,7 +191,7 @@ module HasAttributes ).pluck(:id) # Todo these two queries should be able to be joined into one - name_field = AttributeField.find_by( + AttributeField.find_by( user_id: user_id, attribute_category_id: category_ids, field_type: 'universe' @@ -205,7 +205,7 @@ module HasAttributes ).pluck(:id) # Todo these two queries should be able to be joined into one - field = AttributeField.find_by( + AttributeField.find_by( user_id: user_id, attribute_category_id: category_ids, label: label, diff --git a/app/models/page_data/attribute_category.rb b/app/models/page_data/attribute_category.rb index 5f7895d9..8ba9c799 100644 --- a/app/models/page_data/attribute_category.rb +++ b/app/models/page_data/attribute_category.rb @@ -40,12 +40,6 @@ class AttributeCategory < ApplicationRecord entity_type.titleize.constantize end - private - - def ensure_name - self.name ||= "#{label}-#{Time.now.to_i}".underscore.gsub(' ', '_') - end - def backfill_categories_ordering! content_type_class = entity_type.titleize.constantize category_owner = User.find(user_id) @@ -89,4 +83,10 @@ class AttributeCategory < ApplicationRecord end end end + + private + + def ensure_name + self.name ||= "#{label}-#{Time.now.to_i}".underscore.gsub(' ', '_') + end end diff --git a/app/views/content/attributes.html.erb b/app/views/content/attributes.html.erb index 875340fc..2db3501d 100644 --- a/app/views/content/attributes.html.erb +++ b/app/views/content/attributes.html.erb @@ -11,7 +11,10 @@
    menu <%= attribute_category.icon %> - <%= attribute_category.label %> +
    + <%= attribute_category.label %> + #<%= attribute_category.position.inspect %> +
    <% if hidden_category %> —hidden <% end %> diff --git a/db/schema.rb b/db/schema.rb index d5780f17..1fc6de40 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -874,6 +874,7 @@ ActiveRecord::Schema.define(version: 2019_09_08_015515) do t.integer "father_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["father_id", "character_id", nil], name: "index_fatherships_on_father_id_and_character_id_and_deleted_at" end create_table "flora_eaten_bies", force: :cascade do |t| @@ -1512,6 +1513,7 @@ ActiveRecord::Schema.define(version: 2019_09_08_015515) do t.integer "mother_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["mother_id", "character_id", nil], name: "index_motherships_on_mother_id_and_character_id_and_deleted_at" end create_table "notable_cities_relationships", force: :cascade do |t| From eda59a26726f477fbd857f57b98098a04d8b168e Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 7 Sep 2019 22:48:57 -0500 Subject: [PATCH 12/12] backfill fix --- app/models/page_data/attribute_category.rb | 2 +- app/views/content/attributes.html.erb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/page_data/attribute_category.rb b/app/models/page_data/attribute_category.rb index 8ba9c799..e2fb6458 100644 --- a/app/models/page_data/attribute_category.rb +++ b/app/models/page_data/attribute_category.rb @@ -44,7 +44,7 @@ class AttributeCategory < ApplicationRecord content_type_class = entity_type.titleize.constantize category_owner = User.find(user_id) - categories = content_type_class.attribute_categories(category_owner, show_hidden: true) + categories = content_type_class.attribute_categories(category_owner, show_hidden: true).to_a ActiveRecord::Base.transaction do categories.each.with_index do |content_to_order, index| diff --git a/app/views/content/attributes.html.erb b/app/views/content/attributes.html.erb index 2db3501d..185be7ac 100644 --- a/app/views/content/attributes.html.erb +++ b/app/views/content/attributes.html.erb @@ -13,7 +13,6 @@ <%= attribute_category.icon %>
    <%= attribute_category.label %> - #<%= attribute_category.position.inspect %>
    <% if hidden_category %> —hidden