Открыть боковую панель
nt_test121
nt_project_9da4a5yt9x4b
Коммиты
b0c8f2b1
Не подтверждена
Коммит
b0c8f2b1
создал
Сен 12, 2019
по автору
Francisco Javier López
Просмотр файлов
Adding limit and avoid reordering in count queries
владелец
f0c9916a
Изменения
1
Скрыть пробелы
Построчно
Рядом
lib/gitlab/snippet_search_results.rb
Просмотр файла @
b0c8f2b1
...
...
@@ -3,6 +3,7 @@
module
Gitlab
class
SnippetSearchResults
<
SearchResults
include
SnippetsHelper
include
Gitlab
::
Utils
::
StrongMemoize
attr_reader
:limit_snippets
...
...
@@ -25,33 +26,37 @@ def objects(scope, page = nil)
def
formatted_count
(
scope
)
case
scope
when
'snippet_titles'
snippet_titles_count
.
to_s
formatted_limited_count
(
limited_
snippet_titles_count
)
when
'snippet_blobs'
snippet_blobs_count
.
to_s
formatted_limited_count
(
limited_
snippet_blobs_count
)
else
super
end
end
def
snippet_titles_count
@snippet_titles_count
||=
snippet_titles
.
count
def
limited_snippet_titles_count
strong_memoize
(
:limited_snippet_titles_count
)
do
limited_count
(
snippet_titles
)
end
end
def
snippet_blobs_count
@snippet_blobs_count
||=
snippet_blobs
.
count
def
limited_snippet_blobs_count
strong_memoize
(
:limited_snippet_blobs_count
)
do
limited_count
(
snippet_blobs
)
end
end
private
# rubocop: disable CodeReuse/ActiveRecord
def
snippet_titles
limit_snippets
.
search
(
query
).
order
(
'updated_at DESC'
).
includes
(
:author
)
limit_snippets
.
search
(
query
).
re
order
(
'updated_at DESC'
).
includes
(
:author
)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
snippet_blobs
limit_snippets
.
search_code
(
query
).
order
(
'updated_at DESC'
).
includes
(
:author
)
limit_snippets
.
search_code
(
query
).
re
order
(
'updated_at DESC'
).
includes
(
:author
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать