2018-03-17 18:26:18 +05:30
|
|
|
# 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
|
2023-03-04 22:38:38 +05:30
|
|
|
user.keys.auth
|
2018-03-17 18:26:18 +05:30
|
|
|
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
|