Skip to content

Deduplicate Logic in User#using_license_seat?

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

The logic that constitutes a billable user is duplicated multiple places in the application code. Users#using_license_seat? is one such place. In an effort to reduce the number of places that we define what constitutes a billable user, we may be able to refactor this method to rely on the Users.billable scope.

The method currently looks like this:

    def using_license_seat?
      active? &&
      !internal? &&
      !project_bot? &&
      has_current_license? &&
      paid_in_current_license?
    end

But it may be possible to refactor it to this or something that similarly leverages existing logic:

    def using_license_seat?
      has_current_license? && self.class.billable.include?(self)
    end

One important consideration for this refactoring will be the performance of the database queries.

This is broken out from Technical Spike - refactor billable users calcu... (#375638 - closed).

See original notes here: #375638 (comment 1160988623)

Edited by 🤖 GitLab Bot 🤖