Skip to content
Snippets Groups Projects

Enable user searching by partial email for admins

What does this MR do and why?

This MR enables searching users by partial email match for admin accounts

Screenshots or screen recordings

Before After
before after

How to set up and validate locally

  1. Go to Admin -> Users
  2. Fill in search field with partially matching email address
  3. Search for users

Users with partially matching emails should be found

Related to #20381 (closed)

New SQL queries

User.search("search", with_private_emails: true)

Raw SQL
SELECT "users".* FROM "users" WHERE ("users"."email" = 'search' OR "users"."id" = (SELECT "emails"."user_id" FROM "emails" WHERE "emails"."email" = 'search' AND "emails"."confirmed_at" IS NOT NULL LIMIT 1) OR "users"."name" ILIKE '%search%' OR "users"."username" ILIKE '%search%') ORDER BY CASE
  WHEN LOWER(users.public_email) = 'search' THEN 0
  WHEN LOWER(users.username) = 'search' THEN 1
  WHEN LOWER(users.name) = 'search' THEN 2
  ELSE 3
END
 ASC, "users"."name" ASC, "users"."id" ASC
Query plan
 Sort  (cost=6.31..6.31 rows=2 width=2435) (actual time=0.537..0.538 rows=0 loops=1)
   Sort Key: (CASE WHEN (lower((users.public_email)::text) = 'search'::text) THEN 0 WHEN (lower((users.username)::text) = 'search'::text) THEN 1 WHEN (lower((users.name)::text) = 'search'::text) THEN 2 ELSE 3 END), users.name, users.id
   Sort Method: quicksort  Memory: 25kB
   InitPlan 1 (returns $0)
     ->  Limit  (cost=0.00..1.85 rows=1 width=4) (actual time=0.051..0.051 rows=0 loops=1)
           ->  Seq Scan on emails  (cost=0.00..1.85 rows=1 width=4) (actual time=0.048..0.049 rows=0 loops=1)
                 Filter: ((confirmed_at IS NOT NULL) AND ((email)::text = 'search'::text))
                 Rows Removed by Filter: 81
   ->  Seq Scan on users  (cost=0.00..4.45 rows=2 width=2435) (actual time=0.506..0.506 rows=0 loops=1)
         Filter: (((email)::text = 'search'::text) OR (id = $0) OR ((name)::text ~~* '%search%'::text) OR ((username)::text ~~* '%search%'::text))
         Rows Removed by Filter: 71
 Planning Time: 5.458 ms
 Execution Time: 0.683 ms
(13 rows)
Edited by Zakir Dzhamaliddinov

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Zakir Dzhamaliddinov changed the description

    changed the description

  • added 5712 commits

    Compare with previous version

  • Mohamed Hamda approved this merge request

    approved this merge request

  • added 1 commit

    Compare with previous version

  • 41 Warnings
    :warning: This MR has a Changelog commit for EE, but no code changes in ee/. Consider removing the EE: true trailer from your commits.
    :warning: 1fbe742b: The commit subject must contain at least 3 words. For more information, take a look at our Commit message guidelines.
    :warning: 6d415596: The commit subject must contain at least 3 words. For more information, take a look at our Commit message guidelines.
    :warning: dfaa9c6c: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 4811a6bb: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 09774697: The commit subject must contain at least 3 words. For more information, take a look at our Commit message guidelines.
    :warning: 3e0d9d8a: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: 74813123: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: ef49728c: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 34ef10ad: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: 6ea79991: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: 6c2c0ecf: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: b345a89c: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: ea11fbab: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: 4de00aee: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 0e330c12: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 5e09abc8: The commit subject may not be longer than 72 characters. For more information, take a look at our Commit message guidelines.
    :warning: 5e09abc8: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 004738b9: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 17c326fb: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 167548d2: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 4785df3d: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 5331bef7: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: bd0934a4: The commit subject must contain at least 3 words. For more information, take a look at our Commit message guidelines.
    :warning: 6b14a094: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: bb368753: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: 03803b2b: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 01355b58: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 47bae85c: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: 42bc2f27: The commit subject must contain at least 3 words. For more information, take a look at our Commit message guidelines.
    :warning: 42bc2f27: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: a74d6f62: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: cd6acb5c: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: b83bc3c6: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: b7f163ae: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: c13eb5b8: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    :warning: be39b7cd: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 6ce3562d: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: 216f57e8: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines.
    :warning: This merge request has more than 20 commits which may cause issues in some of the jobs. If you see errors like missing commits, please consider squashing some commits so it is within 20 commits.
    :warning: Labels missing: please ask a reviewer or maintainer to add documentation to this merge request.
    1 Message
    :book: This merge request adds or changes documentation files. A review from the Technical Writing team before you merge is recommended. Reviews can happen after you merge.

    Documentation review

    The following files require a review from a technical writer:

    The review does not need to block merging this merge request. See the:

    Reviewer roulette

    Category Reviewer Maintainer
    backend @atiwari71 profile link current availability (UTC+5.5) @cablett profile link current availability (UTC+12)

    Please check reviewer's status!

    • available Reviewer is available!
    • unavailable Reviewer is unavailable!

    Please refer to documentation page for guidance on how you can benefit from the Reviewer Roulette, or use the GitLab Review Workload Dashboard to find other available reviewers.

    If needed, you can retry the :repeat: danger-review job that generated this comment.

    Generated by :no_entry_sign: Danger

    Edited by Danger Bot
  • added 2184 commits

    Compare with previous version

  • Zakir Dzhamaliddinov reset approvals from @mhamda by pushing to the branch

    reset approvals from @mhamda by pushing to the branch

  • mentioned in merge request !152249 (merged)

  • added groupauthentication label and removed grouptenant scale label

  • @zzaakiirr @tigerwnz I am moving this MR across to groupauthentication, who own the user entity. groupauthentication are taking over the related issue as well. We discussed that we definitely cannot add these indexes on Gitlab.com due to performance concerns (Saturation of lock_manager lwlocks (gitlab-com/gl-infra&1129)), so I wanted to check with you @zzaakiirr whether you would be open to adapting this MR and make it only available to self-managed? This should be achievable as we have existing examples of indexes for self-managed instances only, Tiger can probably point you to the right place for that. Let me know what you think. Please loop in @hsutor, the PM for groupauthentication, in case you have any questions.

    /cc @adil.farrukh

    Edited by Christina Lohr
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading