diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/services/jira_import/users_mapper_service.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/services/jira_import/users_mapper_service.rb')
-rw-r--r-- | app/services/jira_import/users_mapper_service.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/app/services/jira_import/users_mapper_service.rb b/app/services/jira_import/users_mapper_service.rb new file mode 100644 index 00000000000..b5997d77215 --- /dev/null +++ b/app/services/jira_import/users_mapper_service.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module JiraImport + class UsersMapperService + MAX_USERS = 50 + + attr_reader :jira_service, :start_at + + def initialize(jira_service, start_at) + @jira_service = jira_service + @start_at = start_at + end + + def execute + users.to_a.map do |jira_user| + { + jira_account_id: jira_user_id(jira_user), + jira_display_name: jira_user_name(jira_user), + jira_email: jira_user['emailAddress'] + }.merge(match_user(jira_user)) + end + end + + private + + def users + @users ||= client.get(url) + end + + def client + @client ||= jira_service.client + end + + def url + raise NotImplementedError + end + + def jira_user_id(jira_user) + raise NotImplementedError + end + + def jira_user_name(jira_user) + raise NotImplementedError + end + + # TODO: Matching user by email and displayName will be done as the part + # of follow-up issue: https://gitlab.com/gitlab-org/gitlab/-/issues/219023 + def match_user(jira_user) + { gitlab_id: nil, gitlab_username: nil, gitlab_name: nil } + end + end +end |