diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2017-11-17 11:48:32 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-11-17 11:48:32 +0000 |
commit | ff26ea818cb92eabc8fbea1a8385cb5bc6b0a66f (patch) | |
tree | e252a9e7be6cc35d76e78745aa6ed437f1279ed1 /app/models/wiki_page.rb | |
parent | 88d29775bbbeaeff7deff8fb1be58905f2535a96 (diff) | |
download | gitlab-ce-ff26ea818cb92eabc8fbea1a8385cb5bc6b0a66f.tar.gz |
Resolve "Performance issues when loading large number of wiki pages"
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r-- | app/models/wiki_page.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 5f710961f95..bdfef677ef3 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -127,19 +127,24 @@ class WikiPage @version ||= @page.version end - # Returns an array of Gitlab Commit instances. - def versions + def versions(options = {}) return [] unless persisted? - wiki.wiki.page_versions(@page.path) + wiki.wiki.page_versions(@page.path, options) end - def commit - versions.first + def count_versions + return [] unless persisted? + + wiki.wiki.count_page_versions(@page.path) + end + + def last_version + @last_version ||= versions(limit: 1).first end def last_commit_sha - commit&.sha + last_version&.sha end # Returns the Date that this latest version was @@ -151,7 +156,7 @@ class WikiPage # Returns boolean True or False if this instance # is an old version of the page. def historical? - @page.historical? && versions.first.sha != version.sha + @page.historical? && last_version.sha != version.sha end # Returns boolean True or False if this instance |