Commit 893a68ba authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Cache autocomplete or emojis

parent a42d84ec
...@@ -104,15 +104,8 @@ class ProjectsController < ApplicationController ...@@ -104,15 +104,8 @@ class ProjectsController < ApplicationController
autocomplete = ::Projects::AutocompleteService.new(@project) autocomplete = ::Projects::AutocompleteService.new(@project)
participants = ::Projects::ParticipantsService.new(@project).execute(note_type, note_id) participants = ::Projects::ParticipantsService.new(@project).execute(note_type, note_id)
emojis = Emoji.names.map do |e|
{
name: e,
path: view_context.image_url("emoji/#{e}.png")
}
end
@suggestions = { @suggestions = {
emojis: emojis, emojis: autocomplete_emojis,
issues: autocomplete.issues, issues: autocomplete.issues,
mergerequests: autocomplete.merge_requests, mergerequests: autocomplete.merge_requests,
members: participants members: participants
...@@ -189,4 +182,15 @@ class ProjectsController < ApplicationController ...@@ -189,4 +182,15 @@ class ProjectsController < ApplicationController
:wiki_enabled, :visibility_level, :import_url, :last_activity_at, :namespace_id :wiki_enabled, :visibility_level, :import_url, :last_activity_at, :namespace_id
) )
end end
def autocomplete_emojis
Rails.cache.fetch("autocomplete-emoji-#{Emoji::VERSION}") do
Emoji.names.map do |e|
{
name: e,
path: view_context.image_url("emoji/#{e}.png")
}
end
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