redmine_remotes 0.11.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/project_remote_issues_controller/create.rb +1 -1
  3. data/app/controllers/project_remote_issues_controller/update.rb +1 -1
  4. data/app/controllers/remote_trackers_controller.rb +4 -1
  5. data/app/models/remote_issue.rb +11 -0
  6. data/app/models/remote_issue_fetch/base.rb +45 -0
  7. data/app/models/remote_issue_fetch/base/_local_issue.rb +77 -0
  8. data/app/models/remote_issue_fetch/base/_provider_issue.rb +18 -0
  9. data/app/models/remote_issue_fetch/base/_remote_issue.rb +19 -0
  10. data/app/models/remote_issue_fetch/create.rb +44 -0
  11. data/app/models/remote_issue_fetch/create/_local_issue.rb +21 -0
  12. data/app/models/remote_issue_fetch/create/_remote_issue.rb +21 -0
  13. data/app/models/remote_issue_fetch/update.rb +18 -0
  14. data/app/models/remote_issue_fetch/update/_local_issue.rb +15 -0
  15. data/app/models/remote_issue_fetch/update/_remote_issue.rb +15 -0
  16. data/app/models/remote_tracker.rb +7 -1
  17. data/app/models/remote_tracker/find_issue_local_status.rb +1 -1
  18. data/app/models/remote_tracker/remote.rb +32 -8
  19. data/app/models/remote_tracker_fetch.rb +47 -0
  20. data/app/models/remote_tracker_fetch/provider.rb +13 -0
  21. data/app/models/remote_tracker_fetch/remote_issues.rb +27 -0
  22. data/app/models/remote_tracker_fetch/remote_tracker.rb +16 -0
  23. data/app/models/remote_user/find_local_user.rb +3 -3
  24. data/config/initializers/001_patches.rb +1 -0
  25. data/config/locales/en.yml +1 -0
  26. data/config/locales/pt-BR.yml +1 -0
  27. data/config/routes.rb +6 -5
  28. data/db/migrate/20190531171641_create_remote_trackers.rb +1 -1
  29. data/db/migrate/20190910182842_create_remote_users.rb +1 -1
  30. data/db/migrate/20190910203552_create_remote_issue_statuses.rb +1 -1
  31. data/db/migrate/20190912000000_create_remote_issues.rb +1 -1
  32. data/db/migrate/20200602192120_add_outdated_at_to_remote_issues.rb +7 -0
  33. data/db/migrate/20200602194753_add_fetched_at_to_remote_issues.rb +7 -0
  34. data/db/migrate/20200602203020_add_fetched_at_to_remote_trackers.rb +7 -0
  35. data/lib/redmine_remotes/esosti/entities/issue.rb +40 -1
  36. data/lib/redmine_remotes/esosti/instance.rb +8 -5
  37. data/lib/redmine_remotes/jira/entities/issue.rb +6 -2
  38. data/lib/redmine_remotes/jira/instance.rb +4 -17
  39. data/lib/redmine_remotes/jobs/fetch_issues.rb +31 -0
  40. data/lib/redmine_remotes/jobs/fetch_trackers.rb +30 -0
  41. data/lib/redmine_remotes/patches/avmtrf1_rest_provider_instance.rb +22 -0
  42. data/lib/redmine_remotes/version.rb +1 -1
  43. data/lib/tasks/redmine_remotes.rake +16 -11
  44. metadata +49 -27
  45. data/app/models/redmine_remotes/tableless/remote_issue_fetch/base.rb +0 -39
  46. data/app/models/redmine_remotes/tableless/remote_issue_fetch/base/_local_issue.rb +0 -67
  47. data/app/models/redmine_remotes/tableless/remote_issue_fetch/base/_provider_issue.rb +0 -22
  48. data/app/models/redmine_remotes/tableless/remote_issue_fetch/create.rb +0 -57
  49. data/app/models/redmine_remotes/tableless/remote_issue_fetch/create/_local_issue.rb +0 -25
  50. data/app/models/redmine_remotes/tableless/remote_issue_fetch/create/_remote_issue.rb +0 -32
  51. data/app/models/redmine_remotes/tableless/remote_issue_fetch/update.rb +0 -30
  52. data/app/models/redmine_remotes/tableless/remote_issue_fetch/update/_local_issue.rb +0 -19
  53. data/app/models/redmine_remotes/tableless/remote_issue_fetch/update/_remote_issue.rb +0 -19
  54. data/lib/redmine_remotes/rest_provider/http_response.rb +0 -31
  55. data/lib/redmine_remotes/rest_provider/instance.rb +0 -35
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RedmineRemotes
4
- module Tableless
5
- module RemoteIssueFetch
6
- class Create < ::RedmineRemotes::Tableless::RemoteIssueFetch::Base
7
- private
8
-
9
- def create_remote_issue
10
- return true if remote_issue.save
11
-
12
- fetch_record_errors(remote_issue, default_column: default_error_column)
13
- false
14
- end
15
-
16
- def remote_issue_uncached
17
- remote_issue_by_remote_code.if_blank do
18
- ::RemoteIssue.new(remote_tracker: remote_tracker, remote_code: issue_remote_code,
19
- local_issue: local_issue)
20
- end
21
- end
22
-
23
- def remote_issue_by_remote_code_uncached
24
- ::RemoteIssue.where(
25
- remote_tracker: remote_tracker,
26
- remote_code: ::RemoteIssue.remote_code_sanitize(issue_remote_code)
27
- ).first
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac/model'
5
-
6
- module RedmineRemotes
7
- module Tableless
8
- module RemoteIssueFetch
9
- class Update < ::RedmineRemotes::Tableless::RemoteIssueFetch::Base
10
- require_sub __FILE__
11
-
12
- attribute :remote_issue_id, ::Integer
13
- belongs_to :remote_issue
14
-
15
- validates :remote_issue, presence: true
16
-
17
- def default_error_column
18
- :remote_issue_id
19
- end
20
-
21
- def save
22
- return false unless valid?
23
- return false unless save_local_issue
24
-
25
- true
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RedmineRemotes
4
- module Tableless
5
- module RemoteIssueFetch
6
- class Update < ::RedmineRemotes::Tableless::RemoteIssueFetch::Base
7
- private
8
-
9
- def local_issue
10
- remote_issue.local_issue
11
- end
12
-
13
- def local_tracker
14
- local_issue.if_present(&:tracker)
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RedmineRemotes
4
- module Tableless
5
- module RemoteIssueFetch
6
- class Update < ::RedmineRemotes::Tableless::RemoteIssueFetch::Base
7
- private
8
-
9
- def issue_remote_code
10
- remote_issue.remote_code
11
- end
12
-
13
- def remote_tracker
14
- remote_issue.remote_tracker
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RedmineRemotes
4
- module RestProvider
5
- class HttpResponse < ::StandardError
6
- class << self
7
- def new_from_curl_easy(curl_easy)
8
- new(
9
- curl_easy.url,
10
- curl_easy.status.to_i,
11
- curl_easy.body_str
12
- )
13
- end
14
- end
15
-
16
- attr_reader :url, :status, :body
17
-
18
- def initialize(url, status, body)
19
- @url = url
20
- @status = status
21
- @body = body
22
- end
23
-
24
- def body_or_raise
25
- return body if status == 200
26
-
27
- raise self
28
- end
29
- end
30
- end
31
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avmtrf1/rest_provider/instance'
4
- require 'curb'
5
- require 'json'
6
-
7
- module RedmineRemotes
8
- module RestProvider
9
- # Abstract methods
10
- # * parse_issue_id(global_issue_id)
11
- # * self.build_service_url(service_url_suffix)
12
- # * self.issue_get_url_suffix(provider_issue_id)
13
- class Instance < ::Avmtrf1::RestProvider::Instance
14
- attr_reader :remote_tracker
15
-
16
- def initialize(remote_tracker, root_url, username, password)
17
- @remote_tracker = remote_tracker
18
- super(root_url, username, password)
19
- end
20
-
21
- def request(service_url_suffix)
22
- JSON.parse(super(service_url_suffix).body_or_raise)
23
- end
24
-
25
- private
26
-
27
- # @return [RedmineRemotes::RestProvider::HttpResponse]
28
- def curl_perform(curl)
29
- return ::RedmineRemotes::RestProvider::HttpResponse.new_from_curl_easy(curl) if curl.perform
30
-
31
- raise 'Curl failed'
32
- end
33
- end
34
- end
35
- end