Add fuzzy-search on full path in Groups API
What does this MR do?
Related to #258215 (closed)
This change adds new column to fuzzy-search in Groups API to filter on full path.
Migrations
$ bin/rails db:migrate
== 20201021101956 AddIndexRouteOnNameTrigramToRoute: migrating ================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:routes, :name, {:name=>"index_route_on_name_trigram", :using=>:gin, :opclass=>{:name=>:gin_trgm_ops}, :algorithm=>:concurrently})
-> 0.0027s
-- execute("SET statement_timeout TO 0")
-> 0.0004s
-- add_index(:routes, :name, {:name=>"index_route_on_name_trigram", :using=>:gin, :opclass=>{:name=>:gin_trgm_ops}, :algorithm=>:concurrently})
-> 0.0051s
-- execute("RESET ALL")
-> 0.0004s
== 20201021101956 AddIndexRouteOnNameTrigramToRoute: migrated (0.0093s) =======
$ bin/rails db:rollback
== 20201021101956 AddIndexRouteOnNameTrigramToRoute: reverting ================
-- transaction_open?()
-> 0.0000s
-- indexes(:routes)
-> 0.0038s
-- execute("SET statement_timeout TO 0")
-> 0.0004s
-- remove_index(:routes, {:algorithm=>:concurrently, :name=>"index_route_on_name_trigram"})
-> 0.0021s
-- execute("RESET ALL")
-> 0.0004s
== 20201021101956 AddIndexRouteOnNameTrigramToRoute: reverted (0.0075s) =======
Queries
exec CREATE INDEX index_routes_on_name_trigram ON routes USING gin (name gin_trgm_ops);
The query has been executed. Duration: 9.218 min
SELECT "namespaces".*
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND (
"namespaces"."id" IN (
SELECT "routes"."source_id"
FROM "routes"
WHERE "routes"."path" ILIKE '%root1/security%'
)
OR "namespaces"."name" ILIKE '%root1/security%'
)
LIMIT 20 OFFSET 0
https://explain.depesz.com/s/3HU5 (~103ms)
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Alan (Maciej) Paruszewski