Ability for Self-managed add on eligible users sort by name/activity
What does this MR do and why?
This MR adds the ability for customers to sort add_on eligible users based on Name
or Last activity
under http://localhost:3000/admin/code_suggestions. This is a sibling implementation to the SaaS version here: Ability for SaaS add on eligible users sort opt... (!165162 - merged)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Sort | Results |
---|---|
NAME_ASC |
|
NAME_DESC |
|
LAST_ACTIVITY_ON_ASC |
|
LAST_ACTIVITY_ON_DESC |
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Needs both
gdk
and CustomersDot running forSelf-managed
(setup guide) - In Rails console, enable Code Suggestions
Feature.enable(:hamilton_seat_management)
- In Rails console, enable the filtering capabilities
Feature.enable(:enable_add_on_users_filtering)
To assign Code Suggestions seats to your group:
- In Rails console,
add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"}
- In Rails console,
GitlabSubscriptions::AddOnPurchase.create!(add_on: add_on, expires_on: 21.month.from_now, quantity: 5, purchase_xid: 'A-S0002')
- Visit admin section's Duo area
http://localhost:3000/admin/code_suggestions
Database Review
SQL 1 name_asc
name_asc
SELECT
"users".*
FROM
"users"
WHERE ("users"."state" IN ('active'))
AND "users"."user_type" IN (0, 6, 4, 13)
AND "users"."user_type" IN (0, 4, 5, 15, 17)
AND "users"."user_type" IN (0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
ORDER BY
LOWER("users"."name") ASC
SQL 2 name_desc
name_desc
SELECT
"users".*
FROM
"users"
WHERE ("users"."state" IN ('active'))
AND "users"."user_type" IN (0, 6, 4, 13)
AND "users"."user_type" IN (0, 4, 5, 15, 17)
AND "users"."user_type" IN (0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
ORDER BY
LOWER("users"."name") DESC
SQL 3 last_activity_on_asc
last_activity_on_asc
SELECT
"users".*
FROM
"users"
WHERE ("users"."state" IN ('active'))
AND "users"."user_type" IN (0, 6, 4, 13)
AND "users"."user_type" IN (0, 4, 5, 15, 17)
AND "users"."user_type" IN (0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
ORDER BY
"users"."last_activity_on" ASC NULLS FIRST,
"users"."id" DESC
SQL 4 last_activity_on_desc
last_activity_on_desc
SELECT
"users".*
FROM
"users"
WHERE ("users"."state" IN ('active'))
AND "users"."user_type" IN (0, 6, 4, 13)
AND "users"."user_type" IN (0, 4, 5, 15, 17)
AND "users"."user_type" IN (0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
ORDER BY
"users"."last_activity_on" DESC NULLS LAST,
"users"."id" ASC
Related to #480865 and https://gitlab.com/gitlab-org/gitlab/-/issues/480856