Skip to content

Commit 7da13fe

Browse files
committed
Add a simple cache for Gitlab::GithubImport::Client#user
1 parent 2d1e0a0 commit 7da13fe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/gitlab/github_import/client.rb

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def initialize(access_token, host: nil, api_version: 'v3')
1010
@access_token = access_token
1111
@host = host.to_s.sub(%r{/+\z}, '')
1212
@api_version = api_version
13+
@users = {}
1314

1415
if access_token
1516
::Octokit.auto_paginate = false
@@ -64,6 +65,13 @@ def respond_to?(method)
6465
api.respond_to?(method) || super
6566
end
6667

68+
def user(login)
69+
return nil unless login.present?
70+
return @users[login] if @users.key?(login)
71+
72+
@users[login] = api.user(login)
73+
end
74+
6775
private
6876

6977
def api_endpoint

0 commit comments

Comments
 (0)