Commit 32778eb0 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'fj-reduce-gitaly-calls-snippet-rest-endpoints' into 'master'

Reduce number of gitaly calls in Snippet REST list endpoints

See merge request gitlab-org/gitlab!63735
parents 818eed1b 913e8982
......@@ -5,16 +5,22 @@ module API
class Snippet < BasicSnippet
expose :author, using: Entities::UserBasic
expose :file_name do |snippet|
snippet.file_name_on_repo || snippet.file_name
snippet_files.first || snippet.file_name
end
expose :files do |snippet, options|
snippet.list_files.map do |file|
snippet_files.map do |file|
{
path: file,
raw_url: Gitlab::UrlBuilder.build(snippet, file: file, ref: snippet.repository.root_ref)
}
end
end
private
def snippet_files
@snippet_files ||= object.list_files
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment