summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-02-20 01:05:20 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-02-20 14:48:12 -0300
commit7da13fee84eb65acb756de96c3921ecaabc62bd3 (patch)
tree2b200a2285ab98aaea74c879219048cfa3887b9a
parent2d1e0a081110618e8f64336324c9b8e43caae4ff (diff)
downloadgitlab-ce-7da13fee84eb65acb756de96c3921ecaabc62bd3.tar.gz
Add a simple cache for Gitlab::GithubImport::Client#user
-rw-r--r--lib/gitlab/github_import/client.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb
index ba869faa92e..7dbeec5b010 100644
--- a/lib/gitlab/github_import/client.rb
+++ b/lib/gitlab/github_import/client.rb
@@ -10,6 +10,7 @@ module Gitlab
@access_token = access_token
@host = host.to_s.sub(%r{/+\z}, '')
@api_version = api_version
+ @users = {}
if access_token
::Octokit.auto_paginate = false
@@ -64,6 +65,13 @@ module Gitlab
api.respond_to?(method) || super
end
+ def user(login)
+ return nil unless login.present?
+ return @users[login] if @users.key?(login)
+
+ @users[login] = api.user(login)
+ end
+
private
def api_endpoint