diff options
author | Sean McGivern <sean@gitlab.com> | 2019-01-04 09:26:59 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-01-04 09:26:59 +0000 |
commit | 4543ef099d29b383462bcc1c71973c43385cd8dc (patch) | |
tree | afd025be98e320da2449e013ef302b122892f670 | |
parent | 8600043bc71120399c7e97ff74cadc8d0ca1d4b1 (diff) | |
parent | 40f31486a8397c9142a0d5d0434b02d578aa8a67 (diff) | |
download | gitlab-ce-4543ef099d29b383462bcc1c71973c43385cd8dc.tar.gz |
Merge branch '44353-improve-snippet-search-performance' into 'master'
Remove redundant counts in snippets search
Closes #44353
See merge request gitlab-org/gitlab-ce!23952
-rw-r--r-- | app/helpers/search_helper.rb | 4 | ||||
-rw-r--r-- | app/views/search/_results.html.haml | 2 | ||||
-rw-r--r-- | changelogs/unreleased/44353-improve-snippet-search-performance.yml | 5 |
3 files changed, 8 insertions, 3 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 80cc568820a..0ee76a51f7d 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -24,10 +24,10 @@ module SearchHelper end def search_entries_info(collection, scope, term) - return unless collection.count > 0 + return if collection.to_a.empty? from = collection.offset_value + 1 - to = collection.offset_value + collection.count + to = collection.offset_value + collection.to_a.size count = collection.total_count "Showing #{from} - #{to} of #{count} #{scope.humanize(capitalize: false)} for \"#{term}\"" diff --git a/app/views/search/_results.html.haml b/app/views/search/_results.html.haml index ab56f48ba4d..c4d52431d6e 100644 --- a/app/views/search/_results.html.haml +++ b/app/views/search/_results.html.haml @@ -1,4 +1,4 @@ -- if @search_objects.empty? +- if @search_objects.to_a.empty? = render partial: "search/results/empty" - else .row-content-block diff --git a/changelogs/unreleased/44353-improve-snippet-search-performance.yml b/changelogs/unreleased/44353-improve-snippet-search-performance.yml new file mode 100644 index 00000000000..2ecbcef8843 --- /dev/null +++ b/changelogs/unreleased/44353-improve-snippet-search-performance.yml @@ -0,0 +1,5 @@ +--- +title: Improve snippet search performance by removing duplicate counts +merge_request: 23952 +author: +type: performance |