Welcome to mirror list, hosted at ThFree Co, Russian Federation.

users_mapper_service.rb « jira_import « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b5997d772155392cf25992db072fd6d16cba9b62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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