Cache autocomplete or emojis
This commit is contained in:
parent
a42d84eca3
commit
893a68baf3
1 changed files with 12 additions and 8 deletions
|
@ -104,15 +104,8 @@ class ProjectsController < ApplicationController
|
|||
autocomplete = ::Projects::AutocompleteService.new(@project)
|
||||
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 = {
|
||||
emojis: emojis,
|
||||
emojis: autocomplete_emojis,
|
||||
issues: autocomplete.issues,
|
||||
mergerequests: autocomplete.merge_requests,
|
||||
members: participants
|
||||
|
@ -189,4 +182,15 @@ class ProjectsController < ApplicationController
|
|||
:wiki_enabled, :visibility_level, :import_url, :last_activity_at, :namespace_id
|
||||
)
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue