diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-08 12:35:31 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-08 12:35:42 +0200 |
commit | 52a89f20229285183eb6ecc9e9da444d004be5b3 (patch) | |
tree | ac6c997ff62a7d0d3756f23f37bc990382e2893e | |
parent | 2c650b6f30d2e76cf632d6ce5771859aed67ac48 (diff) | |
download | gitlab-ce-52a89f20229285183eb6ecc9e9da444d004be5b3.tar.gz |
Memoize MR merged/closed events retrievalmemoize_merge_request_events
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/models/merge_request.rb | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG index 09f2c44e02c..f6fb9b7d257 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -45,6 +45,7 @@ v 8.10.0 (unreleased) - RailsCache metris now includes fetch_hit/fetch_miss and read_hit/read_miss info. - Allow [ci skip] to be in any case and allow [skip ci]. !4785 (simon_w) - Set import_url validation to be more strict + - Memoize MR merged/closed events retrieval - Add basic system information like memory and disk usage to the admin panel - Don't garbage collect commits that have related DB records like comments - More descriptive message for git hooks and file locks diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 083e93f1ee7..393d8a72657 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -318,11 +318,11 @@ class MergeRequest < ActiveRecord::Base end def merge_event - self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::MERGED).last + @merge_event ||= target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::MERGED).last end def closed_event - self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::CLOSED).last + @closed_event ||= target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::CLOSED).last end WIP_REGEX = /\A\s*(\[WIP\]\s*|WIP:\s*|WIP\s+)+\s*/i.freeze |