summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-06-01 09:01:08 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-06-01 09:01:08 +0000
commit69e31003beee21d9532bdbad979528a48c230679 (patch)
tree73063027af9a1875b4d64fe09803220c7322453e /config
parentdd0f8b8ccc3b5f61e31703f7391a919b702934a5 (diff)
parent78207b95ca7795c82bfc14fdf35422714906b14d (diff)
downloadgitlab-ce-69e31003beee21d9532bdbad979528a48c230679.tar.gz
Merge branch 'dm-discussions-n-plus-1' into 'master'
Resolve N+1 query issue with discussions Closes #33013 See merge request !11775
Diffstat (limited to 'config')
-rw-r--r--config/initializers/active_record_locking.rb (renamed from config/initializers/ar_monkey_patch.rb)0
-rw-r--r--config/initializers/active_record_preloader.rb15
2 files changed, 15 insertions, 0 deletions
diff --git a/config/initializers/ar_monkey_patch.rb b/config/initializers/active_record_locking.rb
index 9266ff0f615..9266ff0f615 100644
--- a/config/initializers/ar_monkey_patch.rb
+++ b/config/initializers/active_record_locking.rb
diff --git a/config/initializers/active_record_preloader.rb b/config/initializers/active_record_preloader.rb
new file mode 100644
index 00000000000..3b16014f302
--- /dev/null
+++ b/config/initializers/active_record_preloader.rb
@@ -0,0 +1,15 @@
+module ActiveRecord
+ module Associations
+ class Preloader
+ module NoCommitPreloader
+ def preloader_for(reflection, owners, rhs_klass)
+ return NullPreloader if rhs_klass == ::Commit
+
+ super
+ end
+ end
+
+ prepend NoCommitPreloader
+ end
+ end
+end