Skip to content

Ability for Self-managed add on eligible users sort by name/activity

Divya Mahadevan requested to merge 480865-add-on-users-sort-sm into master

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)

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 Screenshot 2024-09-09 at 10.56.00.png
NAME_DESC Screenshot 2024-09-09 at 10.56.11.png
LAST_ACTIVITY_ON_ASC Screenshot 2024-09-09 at 10.56.30.png
LAST_ACTIVITY_ON_DESC Screenshot 2024-09-09 at 10.56.21.png

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Needs both gdk and CustomersDot running for Self-managed (setup guide)
  2. In Rails console, enable Code Suggestions Feature.enable(:hamilton_seat_management)
  3. In Rails console, enable the filtering capabilities Feature.enable(:enable_add_on_users_filtering)

To assign Code Suggestions seats to your group:

  1. In Rails console, add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"}
  2. In Rails console, GitlabSubscriptions::AddOnPurchase.create!(add_on: add_on, expires_on: 21.month.from_now, quantity: 5, purchase_xid: 'A-S0002')
  3. Visit admin section's Duo area http://localhost:3000/admin/code_suggestions

Database Review

SQL 1 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

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

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

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

Edited by Divya Mahadevan

Merge request reports