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

Add repository_html_url

Oliver Güntherbbf6e4e4b444
diff --git a/modules/github_integration/db/migrate/20230316080525_add_repository_html_url.rb b/modules/github_integration/db/migrate/20230316080525_add_repository_html_url.rb
new file mode 100644
index 00000000000..78d9bc1a885
--- /dev/null
+++ b/modules/github_integration/db/migrate/20230316080525_add_repository_html_url.rb
@@ -0,0 +1,15 @@
+class AddRepositoryHtmlUrl < ActiveRecord::Migration[7.0]
+ def change
+ change_table :github_pull_requests, bulk: true do |t|
+ t.string :repository_html_url
+ end
+
+ execute <<~SQL.squish
+ UPDATE github_pull_requests
+ SET repository_html_url = CONCAT(
+ substring(github_html_url from 0 for position(repository IN github_html_url)),
+ repository
+ )
+ SQL
+ end
+end
diff --git a/modules/github_integration/lib/api/v3/github_pull_requests/github_pull_request_representer.rb b/modules/github_integration/lib/api/v3/github_pull_requests/github_pull_request_representer.rb
index 653b38a3c30..9f0fa49f9a1 100644
--- a/modules/github_integration/lib/api/v3/github_pull_requests/github_pull_request_representer.rb
+++ b/modules/github_integration/lib/api/v3/github_pull_requests/github_pull_request_representer.rb
@@ -55,8 +55,9 @@ module API
property :state,
render_nil: true
- property :repository,
- render_nil: true
+ property :repository
+
+ property :repository_html_url
date_time_property :github_updated_at,
render_nil: true,
diff --git a/modules/github_integration/lib/open_project/github_integration/services/upsert_pull_request.rb b/modules/github_integration/lib/open_project/github_integration/services/upsert_pull_request.rb
index 2488f1925b5..89ed6dad3a8 100644
--- a/modules/github_integration/lib/open_project/github_integration/services/upsert_pull_request.rb
+++ b/modules/github_integration/lib/open_project/github_integration/services/upsert_pull_request.rb
@@ -66,6 +66,9 @@ module OpenProject::GithubIntegration::Services
repository: payload.fetch('base')
.fetch('repo')
.fetch('full_name'),
+ repository_html_url: payload.fetch('base')
+ .fetch('repo')
+ .fetch('html_url'),
draft: payload.fetch('draft'),
merged: payload.fetch('merged'),
merged_by: github_user_id(payload['merged_by']),