accelerate speed
This commit is contained in:
parent
52af999549
commit
ec834f143b
|
@ -181,7 +181,13 @@ class GalleriesController < ApplicationController
|
||||||
def widget
|
def widget
|
||||||
@album_setting = AlbumSetting.first
|
@album_setting = AlbumSetting.first
|
||||||
tags = OrbitHelper.widget_tags.empty? ? ["all"] : OrbitHelper.widget_tags
|
tags = OrbitHelper.widget_tags.empty? ? ["all"] : OrbitHelper.widget_tags
|
||||||
album_ids = Album.filter_by_widget_categories(OrbitHelper.widget_categories,false).filter_by_tags(tags).pluck(:id)
|
albums = Album.filter_by_widget_categories(OrbitHelper.widget_categories,false).filter_by_tags(tags).to_a
|
||||||
|
album_ids = []
|
||||||
|
albums_map = {}
|
||||||
|
albums.each do |ab|
|
||||||
|
album_ids << ab.id
|
||||||
|
albums_map[ab.id] = ab
|
||||||
|
end
|
||||||
album_color_map = AlbumColor.where(:album_id.in=> album_ids).pluck(:album_id,:color,:album_card_background_color,:album_card_text_color).map{|v| [v[0],v[1..-1]]}.to_h
|
album_color_map = AlbumColor.where(:album_id.in=> album_ids).pluck(:album_id,:color,:album_card_background_color,:album_card_text_color).map{|v| [v[0],v[1..-1]]}.to_h
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
counts = OrbitHelper.widget_data_count
|
counts = OrbitHelper.widget_data_count
|
||||||
|
@ -189,18 +195,20 @@ class GalleriesController < ApplicationController
|
||||||
images = images.each_with_index.collect do |a,i|
|
images = images.each_with_index.collect do |a,i|
|
||||||
colors = album_color_map[a.album_id]
|
colors = album_color_map[a.album_id]
|
||||||
alt_text = (a.description.blank? ? "gallery image" : Nokogiri::HTML(a.description).text().strip)
|
alt_text = (a.description.blank? ? "gallery image" : Nokogiri::HTML(a.description).text().strip)
|
||||||
|
f = a.file
|
||||||
|
ab = albums_map[a.album_id]
|
||||||
{
|
{
|
||||||
"link_text" => "",
|
"link_text" => "",
|
||||||
"link_to_show" => OrbitHelper.widget_more_url + "/" + a.album.to_param + "#" + a.id.to_s,
|
"link_to_show" => OrbitHelper.widget_more_url + "/" + ab.to_param + "#" + a.id.to_s,
|
||||||
"alt_title" => alt_text,
|
"alt_title" => alt_text,
|
||||||
"src" => a.file.url,
|
"src" => f.url,
|
||||||
"thumb-src" => a.file.thumb.url,
|
"thumb-src" => f.thumb.url,
|
||||||
"thumb-large-src" => a.file.thumb_large.url,
|
"thumb-large-src" => f.thumb_large.url,
|
||||||
"image_description" => a.description,
|
"image_description" => a.description,
|
||||||
"image_short_description" => a.title,
|
"image_short_description" => a.title,
|
||||||
"mobile-src" => a.file.mobile.url,
|
"mobile-src" => f.mobile.url,
|
||||||
"theater-src" => a.file.theater.url,
|
"theater-src" => f.theater.url,
|
||||||
"album-name" => a.album.name_translations[I18n.locale],
|
"album-name" => ab.name_translations[I18n.locale],
|
||||||
"album_color" => iterate_data(colors[1],colors[0],@album_setting.album_card_background_color,'transparent'),
|
"album_color" => iterate_data(colors[1],colors[0],@album_setting.album_card_background_color,'transparent'),
|
||||||
"album_card_text_color" => iterate_data(colors[2],@album_setting.album_card_text_color),
|
"album_card_text_color" => iterate_data(colors[2],@album_setting.album_card_text_color),
|
||||||
"i" => i
|
"i" => i
|
||||||
|
|
Loading…
Reference in New Issue