Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

address review remarks

Markus Kahl22a8424f94ff
diff --git a/modules/github_integration/app/models/deploy_target.rb b/modules/github_integration/app/models/deploy_target.rb
index 92563c45d8b..cb4d5942193 100644
--- a/modules/github_integration/app/models/deploy_target.rb
+++ b/modules/github_integration/app/models/deploy_target.rb
@@ -34,7 +34,10 @@ class DeployTarget < ApplicationRecord
has_many :deploy_status_checks, dependent: :destroy
validates_presence_of :host
+ validates_uniqueness_of :host
+
validates_presence_of :type
+
# this is very much specific to the only type of target we support for now, OpenProject
validates_presence_of :api_key
end
diff --git a/modules/github_integration/app/workers/cron/check_deploy_status_job.rb b/modules/github_integration/app/workers/cron/check_deploy_status_job.rb
index b1ed86d3e32..1372811aa5d 100644
--- a/modules/github_integration/app/workers/cron/check_deploy_status_job.rb
+++ b/modules/github_integration/app/workers/cron/check_deploy_status_job.rb
@@ -90,13 +90,13 @@ module Cron
end
def delete_status_check(pull_request, deploy_target)
- # we use `find` and delete it this way to also cover
+ # we use `select` and delete it this way to also cover
# not-yet-persisted records
- check = pull_request
+ checks = pull_request
.deploy_status_checks
- .find { |c| c.deploy_target == deploy_target }
+ .select { |c| c.deploy_target == deploy_target }
- pull_request.deploy_status_checks.delete(check)
+ pull_request.deploy_status_checks.delete(checks)
end
##
@@ -143,6 +143,16 @@ module Cron
return false if data.nil?
+ status_identical?(data) || status_behind?(data)
+ end
+
+ def status_identical?(data)
+ status = data["status"].presence
+
+ status == "identical"
+ end
+
+ def status_behind?(data)
status = data["status"].presence
ahead_by = data["ahead_by"].presence
behind_by = data["behind_by"].presence
diff --git a/modules/github_integration/config/routes.rb b/modules/github_integration/config/routes.rb
index 7fe0aaba47a..2f6f23ab8f4 100644
--- a/modules/github_integration/config/routes.rb
+++ b/modules/github_integration/config/routes.rb
@@ -27,5 +27,5 @@
#++
Rails.application.routes.draw do
- resources :deploy_targets, only: %i[index new edit update create destroy]
+ resources :deploy_targets, only: %i[index new create destroy]
end