Fix timeouts in source:<url> searches and bookmarklet.

* Change the source index on posts from `(lower(source) gin_trgm_ops) WHERE source != ''`
  to just `(source gin_trgm_ops)`. The WHERE clause prevented the index
  from being used in source:<url> searches because we didn't specify
  the `source != ''` clause in the search itself. Excluding blank
  sources only saved a marginal amount of space anyway. This fixes
  timeouts in source:<url> searches and in the bookmarklet (since we do
  a source dupe check on the upload page too).

* Also switch from indexing `lower(name)` to `name` on pools and users.
  We don't need to lowercase the column because GIN indexes can be used
  with both LIKE and ILIKE queries.
This commit is contained in:
evazion
2019-09-02 18:53:27 -05:00
parent ffc693ef37
commit 5df3b01ca2
7 changed files with 44 additions and 11 deletions

View File

@@ -52,6 +52,15 @@ class PoolTest < ActiveSupport::TestCase
end
end
context "Searching pools" do
should "find pools by name" do
@pool = FactoryBot.create(:pool, name: "Test Pool")
assert_equal(@pool.id, Pool.find_by_name("test pool").id)
assert_equal(@pool.id, Pool.search(name_matches: "test pool").first.id)
end
end
context "Creating a pool" do
setup do
@posts = FactoryBot.create_list(:post, 5)