diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-02-20 01:05:20 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-02-20 14:48:12 -0300 |
commit | 7da13fee84eb65acb756de96c3921ecaabc62bd3 (patch) | |
tree | 2b200a2285ab98aaea74c879219048cfa3887b9a | |
parent | 2d1e0a081110618e8f64336324c9b8e43caae4ff (diff) | |
download | gitlab-ce-7da13fee84eb65acb756de96c3921ecaabc62bd3.tar.gz |
Add a simple cache for Gitlab::GithubImport::Client#user
-rw-r--r-- | lib/gitlab/github_import/client.rb | 8 |
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 |