Commit 5ffa5b97 authored by Yorick Peterse's avatar Yorick Peterse
Browse files

Set inverse_of for Project/Services relation

This ensures that code such as this don't run needless SQL queries:

    project.gitlab_issue_tracker_service.project

This also means that if the root `project` eager loads any associations
the Service object will be able to re-use those.
parent be4f4d358459
......@@ -99,6 +99,7 @@
- Remove tanuki logo from side navigation; center on top nav
- Include user relationships when retrieving award_emoji
- Various associations are now eager loaded when parsing issue references to reduce the number of queries executed
- Set inverse_of for Project/Service association to reduce the number of queries
v 8.8.5 (unreleased)
- Ensure branch cleanup regardless of whether the GitHub import process succeeds
......
......@@ -81,7 +81,7 @@
has_one :jira_service, dependent: :destroy
has_one :redmine_service, dependent: :destroy
has_one :custom_issue_tracker_service, dependent: :destroy
has_one :gitlab_issue_tracker_service, dependent: :destroy
has_one :gitlab_issue_tracker_service, dependent: :destroy, inverse_of: :project
has_one :external_wiki_service, dependent: :destroy
has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id"
......
......@@ -18,7 +18,7 @@
after_commit :reset_updated_properties
after_commit :cache_project_has_external_issue_tracker
belongs_to :project
belongs_to :project, inverse_of: :services
has_one :service_hook
validates :project_id, presence: true, unless: Proc.new { |service| service.template? }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment