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)
|
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
|
||||||
: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
|
||||||
|
|
Loading…
Reference in a new issue