diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb index ebb1d7bff..39e5d95f8 100644 --- a/app/models/concerns/searchable.rb +++ b/app/models/concerns/searchable.rb @@ -33,7 +33,6 @@ module Searchable def search_record_attributes { account_id: account_id, - account_key: "account#{account_id}", searchable_type: self.class.name, searchable_id: id, card_id: search_card_id, diff --git a/app/models/search/record/trilogy.rb b/app/models/search/record/trilogy.rb index c4520b7f2..57a94ab2c 100644 --- a/app/models/search/record/trilogy.rb +++ b/app/models/search/record/trilogy.rb @@ -6,7 +6,7 @@ module Search::Record::Trilogy included do self.abstract_class = true - before_save :stem_content + before_save :set_account_key, :stem_content end class_methods do @@ -60,6 +60,10 @@ module Search::Record::Trilogy self.content = Search::Stemmer.stem(content) if content_changed? end + def set_account_key + self.account_key = "account#{account_id}" + end + def highlight(text, show:) if text.present? && attribute?(:query) highlighter = Search::Highlighter.new(query) diff --git a/db/schema.rb b/db/schema.rb index 54bedccb4..f951af36b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -408,21 +408,6 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_21_112416) do t.index ["user_id"], name: "index_search_queries_on_user_id" end - create_table "search_records", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.uuid "account_id", null: false - t.string "account_key", null: false - t.uuid "board_id", null: false - t.uuid "card_id", null: false - t.text "content" - t.datetime "created_at", null: false - t.uuid "searchable_id", null: false - t.string "searchable_type", null: false - t.string "title" - t.index ["account_id"], name: "index_search_records_on_account_id" - t.index ["account_key", "content", "title"], name: "index_search_records_on_account_key_and_content_and_title", type: :fulltext - t.index ["searchable_type", "searchable_id"], name: "index_search_records_on_searchable_type_and_searchable_id", unique: true - end - create_table "search_records_0", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.uuid "account_id", null: false t.string "account_key", default: "", null: false diff --git a/db/schema_sqlite.rb b/db/schema_sqlite.rb index 76c143481..e3444f3fe 100644 --- a/db/schema_sqlite.rb +++ b/db/schema_sqlite.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.2].define(version: 2025_11_20_203100) do +ActiveRecord::Schema[8.2].define(version: 2025_11_21_112416) do create_table "accesses", id: :uuid, force: :cascade do |t| t.datetime "accessed_at" t.uuid "account_id", null: false