Welcome to mirror list, hosted at ThFree Co, Russian Federation.

keys_count_service.rb « users « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 378093f2e1bf73e539c30c1f6b9aca84192ed051 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Users
  # Service class for getting the number of SSH keys that belong to a user.
  class KeysCountService < BaseCountService
    attr_reader :user

    # user - The User for which to get the number of SSH keys.
    def initialize(user)
      @user = user
    end

    def relation_for_count
      user.keys.auth
    end

    def raw?
      # Since we're storing simple integers we don't need all of the additional
      # Marshal data Rails includes by default.
      true
    end

    def cache_key
      "users/key-count-service/#{user.id}"
    end
  end
end