Skip to content

Count Guests with custom roles as billable users in users statistics

What does this MR do and why?

This MR changes how we count and show paid users in admin section for self-managed installation on Ultimate Plan - for admin/dashboard/stats section.

Now we count Guest users with additional custom roles that elevate the guest into the billed seat.

First part of this MR was merged here: !114752 (merged)

Screenshots or screen recordings

Before: Screenshot_2023-03-22_at_12.28.50 After: image

Plans:

main: == 20230321085011 AddColumnToUsersStatistisc: migrating =======================
main: -- add_column(:users_statistics, :with_highest_role_guest_with_custom_role, :integer, {:default=>0, :null=>false})
main:    -> 0.0070s
main: == 20230321085011 AddColumnToUsersStatistisc: migrated (0.0113s) ==============

ci: == 20230321085011 AddColumnToUsersStatistisc: migrating =======================
ci: -- add_column(:users_statistics, :with_highest_role_guest_with_custom_role, :integer, {:default=>0, :null=>false})
ci:    -> 0.0057s
ci: == 20230321085011 AddColumnToUsersStatistisc: migrated (0.0133s) ==============
main: == 20230321085011 AddColumnToUsersStatistisc: reverting =======================
main: -- remove_column(:users_statistics, :with_highest_role_guest_with_custom_role, :integer, {:default=>0, :null=>false})
main:    -> 0.0044s
main: == 20230321085011 AddColumnToUsersStatistisc: reverted (0.0119s) ==============
  1. The only permission we can use right now for testing is :download_code, so we need to comment the line 5 in the MemberRole class (the one that adds the the download_code to the ignored columns).
  2. Add :download_code to the ALL_CUSTOMIZABLE_PERMISSIONS hash.
  3. Add member role that has download_code attribute set to true.
  4. Associate this member role with member of a group on a Guest level.
  5. See the Admin > Users and verify if the guest user with elevating permission is having "Is using seat" badge.
  6. In Rails console run UsersStatistics.create_current_stats!
  7. See numbers in admin/dashboard/stats section.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #395794 (closed)

Edited by Gosia Ksionek

Merge request reports