Class: Gitlab::GithubImport::Clients::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/github_import/clients/proxy.rb

Constant Summary collapse

REPOS_COUNT_CACHE_KEY =
'github-importer/provider-repo-count/%{type}/%{user_id}'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token, client_options) ⇒ Proxy

Returns a new instance of Proxy.



13
14
15
# File 'lib/gitlab/github_import/clients/proxy.rb', line 13

def initialize(access_token, client_options)
  @client = pick_client(access_token, client_options)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/gitlab/github_import/clients/proxy.rb', line 7

def client
  @client
end

Instance Method Details

#count_repos_by(relation_type, user_id) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/gitlab/github_import/clients/proxy.rb', line 23

def count_repos_by(relation_type, user_id)
  return if use_legacy?

  key = format(REPOS_COUNT_CACHE_KEY, type: relation_type, user_id: user_id)

  ::Gitlab::Cache::Import::Caching.read_integer(key, timeout: 5.minutes) ||
    fetch_and_cache_repos_count_via_graphql(relation_type, key)
end

#repos(search_text, options) ⇒ Object



17
18
19
20
21
# File 'lib/gitlab/github_import/clients/proxy.rb', line 17

def repos(search_text, options)
  return { repos: filtered(client.repos, search_text) } if use_legacy?

  fetch_repos_via_graphql(search_text, options)
end