Commit Graph

57 Commits

Author SHA1 Message Date
Donal McBreen b571303385 Don't use Current.account for search records
It doesn't actually work, and even if we could make it work reliably
we are better off if the records always know to go to the right shard.

It does make the interface a bit more complicated as we need to select
the right shard class with `for(account_id)`.
2025-11-25 11:34:41 +00:00
Donal McBreen 2199dcc0c8 Fix name in SQL string 2025-11-21 16:01:05 +00:00
Donal McBreen 6f02cb40b1 Drop unnecessary html_safes 2025-11-21 15:46:31 +00:00
Donal McBreen d09deca038 Fallback to search_records_0, so eager loading has a valid table 2025-11-21 15:35:58 +00:00
Donal McBreen 0989017f62 Fix rubocop 2025-11-21 15:31:00 +00:00
Donal McBreen d48eb523b8 Fix rubocop 2025-11-21 15:30:14 +00:00
Donal McBreen be0ce5efa0 Use dependant delete on fts table 2025-11-21 15:28:25 +00:00
Donal McBreen 525e53a2f7 Add FTS ActiveRecord model
Needs some special handling for the FTS virtual table format. Set the
primary key to rowid and manually specify the columns.
2025-11-21 15:21:11 +00:00
Donal McBreen 04c9d9268b Remove wrapper methods and kwargs 2025-11-21 14:53:17 +00:00
Donal McBreen eecdb486b7 Remove unused attribute 2025-11-21 14:42:28 +00:00
Donal McBreen bef4b86212 Use card_search_records instead of join class method 2025-11-21 14:42:09 +00:00
Donal McBreen ea06b2d46f Simplify and test highlighing 2025-11-21 14:25:38 +00:00
Donal McBreen 6e749d2b5f Drop for_user 2025-11-21 12:39:47 +00:00
Donal McBreen aebe3f97ed Drop parentheses 2025-11-21 12:37:29 +00:00
Donal McBreen 02da6dbf8f Parameterised queries 2025-11-21 12:36:45 +00:00
Donal McBreen 463a5f089a Consolidate scopes and extract search_fields 2025-11-21 12:31:25 +00:00
Donal McBreen f91c41d75a Drop variables 2025-11-21 12:11:15 +00:00
Donal McBreen 01d16f96d4 Remove Search::Record.for_account
Instead we'll compute the table name dynamically based on
Current.account where needed. Also we'll prevent searchable records
from being saved if Current.account is not set, otherwise the after
commit callbacks will fail.
2025-11-21 12:09:21 +00:00
Donal McBreen 4008819390 Use table_name with Current.account to drop for_account 2025-11-21 11:54:21 +00:00
Donal McBreen b92aba383e account_key is MySQL specific 2025-11-21 11:47:28 +00:00
Donal McBreen 2e4d0b38db Fix matching scope after merge 2025-11-21 11:43:01 +00:00
Donal McBreen 366dbd393c Merge branch 'main' into sqlite 2025-11-21 11:39:47 +00:00
Donal McBreen adff4591fe Search with the tenant key
The key has been added and populated so use it for searching.
2025-11-21 11:09:06 +00:00
Donal McBreen 74d1cf735b Only add and fill account_key 2025-11-21 10:20:27 +00:00
Donal McBreen 70dd754cf7 Account key for search records
Add an account key field to improve search performance. This field
allows us to filter the records by account directly in the fulltext
index, so we only need to examine rows belonging to the relevant account.
2025-11-21 09:38:35 +00:00
Donal McBreen 4f6ec19491 Drop comments 2025-11-21 09:15:19 +00:00
Donal McBreen 0e11a139a5 Move quoting 2025-11-21 09:15:19 +00:00
Donal McBreen 62d102578f Table name already correct 2025-11-21 09:15:19 +00:00
Donal McBreen ca17193620 Belongs_to not optional 2025-11-21 09:15:19 +00:00
Donal McBreen 6dfb961b83 Delegate to_s to terms 2025-11-21 09:15:19 +00:00
Donal McBreen 19b0e25eac Split sqlite/mysql record stuff 2025-11-21 09:15:19 +00:00
Donal McBreen a4850fbe73 Remove adapter specific logic from searchable 2025-11-21 09:15:19 +00:00
Donal McBreen bb36b4846f Support SQLite searching 2025-11-21 09:15:19 +00:00
Mike Dalessio 2c765fa03f rubocop: style fixes 2025-11-17 09:12:41 -05:00
Donal McBreen 28efe28f24 Replace Search::Index with Search::Records
Lean on ActiveRecord models for searching and strip out the raw SQL.
Replaces the search_index_* tables with sharded search_records_* tables
as that allows us to use a Search::Record model name.

A Class is dynamically created for each record table shard so that we
and we can access it via the Search::Record.for_account(account_id)
method.
2025-11-17 09:12:40 -05:00
Mike Dalessio fe6df7085f Finish the rollout of account_id to all core data models
Schema:
- add account_id to tables it was missing from
- make account_id a required column everywhere
- add [account_id] indexes, or add `account_id` to existing indices

Models:
- add `belongs_to :account` to all models (default to using a domain
  model's account whenever possible)
- add account_id in all the necessary fixtures
- add account_id to insert_all hashes
- pass account_id to a few initialize calls

Miscellaneous:
- update the import script to set account_id

Note that I'm not adding account_id to the join tables primarily
because I couldn't think of an easy way to populate it without making
it a full Join model, and that was more work than I have time to take
on right now.
2025-11-17 09:12:40 -05:00
Mike Dalessio 6df681991f rubocop: fix style warnings 2025-11-17 09:12:36 -05:00
Donal McBreen 436d2b525b Set creator_id as a UUID 2025-11-17 09:12:36 -05:00
Donal McBreen fc56ad9d7c Combine uuid-old and uuid branch changes
- Switch to binary 16 for UUID keys
- Remove AccountScopedRecord base class, all model use binary uuids now
- Fix the search sql to serialize uuids properly
- Patch the MySQL schema dumper to output binary lengths
2025-11-17 09:12:34 -05:00
Mike Dalessio e4011ef211 Update primary keys on customer data to UUIDs
- schema changes to primary and foreign keys
- fixture changes
- customer data models subclass AccountScopedRecord
- import script updated
2025-11-17 09:12:30 -05:00
Stanko K.R. 6858b96619 Simplify join codes 2025-11-17 09:12:17 -05:00
Stanko K.R. 2f62d91bc3 Remove all special charaters when stemming 2025-11-17 09:12:17 -05:00
Stanko K.R. 1b8828da1d Add tests for the highlighter and stemmer 2025-11-17 09:12:17 -05:00
Stanko K.R. a41085fe00 Show full comment, description or title 2025-11-17 09:12:17 -05:00
Stanko K.R. 2c3062fd86 Add a stemmer and highlighter 2025-11-17 09:12:17 -05:00
Jorge Manrubia aa1ffb3357 Remove AI summaries and semantic searches
We were not using either. We can restore if we revisit.
2025-10-29 11:55:32 +01:00
Stanko Krtalić 0e2c7f7d4d Escape HTML everywhere where html_safe is used (#1114)
* Escape HTML everywhere where html_safe is used
* Mark search results as HTML safe at the attribute
2025-09-16 11:52:15 +02:00
Jorge Manrubia 1c6adf54a8 Restore semantic searches 2025-07-24 16:47:57 +02:00
Jorge Manrubia 9e3dbb0858 Remove semantic searches
We may revisit in the future but we'll go with keyword search only for launch
2025-06-25 09:36:14 +02:00
Jorge Manrubia 0fe54e2047 Save one query 2025-06-24 13:00:30 +02:00