Compare commits

..

3 commits

Author SHA1 Message Date
8aa6eb40a7 Disable advanced mini-profiler tools in production
I'm not really using this lately, and it _only_ creates vulnerability
surface area when not in use; so, while I'm pretty sure we locked this
down correctly to only admin accounts, I'm disabling it just as good
practice. We can add this back later if we need it again!
2024-02-03 08:21:14 -08:00
d6b6ab884d Migration to drop {color,species,zone}_translations
They're no longer referenced in either app! Begone!

(The translated values are still available in the DTI 2020 repository's
history, under `scripts/db`!)
2024-02-03 08:20:18 -08:00
2667ed49ba Fully disable model translations for Color/Species/Zone
Now that DTI 2020 has been deployed without references to the
translations tables, we can stop keeping them in sync!

Next step is to drop the tables and be done with them altogether! (I
have a backup of the public data for this too, as does this repo!)
2024-02-03 08:13:14 -08:00
6 changed files with 36 additions and 80 deletions

View file

@ -1,5 +1,4 @@
class Color < ApplicationRecord
translates # TODO: Remove once we're all done with translations!
has_many :pet_types
scope :alphabetical, -> { order(:name) }
@ -9,16 +8,6 @@ class Color < ApplicationRecord
scope :funny, -> { order(:prank) unless pranks_funny? }
validates :name, presence: true
# Temporary writer to keep the English translation record updated, while
# primarily using the attribute on the model itself.
#
# Once this app and DTI 2020 are both comfortably off the translation system,
# we can remove this!
def name=(new_name)
globalize.write(:en, :name, new_name)
write_attribute(:name, new_name)
end
def as_json(options={})
{id: id, name: name, human_name: human_name}

View file

@ -1,5 +1,4 @@
class Species < ApplicationRecord
translates # TODO: Remove once we're all done with translations!
has_many :pet_types
has_many :alt_styles
@ -9,16 +8,6 @@ class Species < ApplicationRecord
pt = PetType.arel_table
joins(:pet_types).where(pt[:body_id].eq(body_id)).limit(1)
}
# Temporary writer to keep the English translation record updated, while
# primarily using the attribute on the model itself.
#
# Once this app and DTI 2020 are both comfortably off the translation system,
# we can remove this!
def name=(new_name)
globalize.write(:en, :name, new_name)
write_attribute(:name, new_name)
end
def as_json(options={})
super({only: [:id, :name], methods: [:human_name]}.merge(options))

View file

@ -1,6 +1,4 @@
class Zone < ActiveRecord::Base
translates # TODO: Remove once we're all done with translations!
class Zone < ActiveRecord::Base
# When selecting zones that an asset occupies, we allow the zone to set
# whether or not the zone is "sometimes" occupied. This is false by default.
attr_writer :sometimes
@ -11,26 +9,6 @@ class Zone < ActiveRecord::Base
}
scope :for_items, -> { where(arel_table[:type_id].gt(1)) }
# Temporary writer to keep the English translation record updated, while
# primarily using the attribute on the model itself.
#
# Once this app and DTI 2020 are both comfortably off the translation system,
# we can remove this!
def label=(new_label)
globalize.write(:en, :label, new_label)
write_attribute(:label, new_label)
end
# Temporary writer to keep the English translation record updated, while
# primarily using the attribute on the model itself.
#
# Once this app and DTI 2020 are both comfortably off the translation system,
# we can remove this!
def plain_label=(new_plain_label)
globalize.write(:en, :plain_label, new_plain_label)
write_attribute(:plain_label, new_plain_label)
end
def as_json(options={})
super({only: [:id, :depth, :label]}.merge(options))
end

View file

@ -1,3 +0,0 @@
Rails.configuration.to_prepare do
Rack::MiniProfiler.config.enable_advanced_debugging_tools = true
end

View file

@ -0,0 +1,34 @@
class DropTranslationsForColorsAndSpeciesAndZones < ActiveRecord::Migration[7.1]
def change
drop_table "color_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
t.integer "color_id"
t.string "locale"
t.string "name"
t.datetime "created_at", precision: nil
t.datetime "updated_at", precision: nil
t.index ["color_id"], name: "index_color_translations_on_color_id"
t.index ["locale"], name: "index_color_translations_on_locale"
end
drop_table "species_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
t.integer "species_id"
t.string "locale"
t.string "name"
t.datetime "created_at", precision: nil
t.datetime "updated_at", precision: nil
t.index ["locale"], name: "index_species_translations_on_locale"
t.index ["species_id"], name: "index_species_translations_on_species_id"
end
drop_table "zone_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
t.integer "zone_id"
t.string "locale"
t.string "label"
t.string "plain_label"
t.datetime "created_at", precision: nil
t.datetime "updated_at", precision: nil
t.index ["locale"], name: "index_zone_translations_on_locale"
t.index ["zone_id"], name: "index_zone_translations_on_zone_id"
end
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_02_01_134440) do
ActiveRecord::Schema[7.1].define(version: 2024_02_03_161355) do
create_table "alt_styles", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.integer "species_id", null: false
t.integer "color_id", null: false
@ -70,16 +70,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_01_134440) do
t.index ["user_id"], name: "index_closet_lists_on_user_id"
end
create_table "color_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
t.integer "color_id"
t.string "locale"
t.string "name"
t.datetime "created_at", precision: nil
t.datetime "updated_at", precision: nil
t.index ["color_id"], name: "index_color_translations_on_color_id"
t.index ["locale"], name: "index_color_translations_on_locale"
end
create_table "colors", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
t.boolean "basic"
t.boolean "standard"
@ -249,16 +239,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_01_134440) do
t.string "name", null: false
end
create_table "species_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
t.integer "species_id"
t.string "locale"
t.string "name"
t.datetime "created_at", precision: nil
t.datetime "updated_at", precision: nil
t.index ["locale"], name: "index_species_translations_on_locale"
t.index ["species_id"], name: "index_species_translations_on_species_id"
end
create_table "swf_assets", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
t.string "type", limit: 7, null: false
t.integer "remote_id", limit: 3, null: false
@ -296,17 +276,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_01_134440) do
t.boolean "support_staff", default: false, null: false
end
create_table "zone_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
t.integer "zone_id"
t.string "locale"
t.string "label"
t.string "plain_label"
t.datetime "created_at", precision: nil
t.datetime "updated_at", precision: nil
t.index ["locale"], name: "index_zone_translations_on_locale"
t.index ["zone_id"], name: "index_zone_translations_on_zone_id"
end
create_table "zones", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
t.integer "depth"
t.integer "type_id"