Changes in query for default widget
This commit is contained in:
parent
04d3e177d5
commit
d01968dcd0
|
@ -31,13 +31,12 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
end
|
end
|
||||||
result = eval("#{ori_class_name}.where(:id=>result_ids)")
|
result = eval("#{ori_class_name}.where(:id=>result_ids)")
|
||||||
elsif params["category_id"].blank? #no tag no cate
|
elsif params["category_id"].blank? #no tag no cate
|
||||||
|
result = eval(@default_widget["query"])
|
||||||
result = eval(@default_widget["query"])
|
else #no tag has cate
|
||||||
else #no tag has cate
|
result = eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id'])")
|
||||||
result = eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id'])")
|
|
||||||
end
|
end
|
||||||
date_now = Time.now
|
date_now = Time.now
|
||||||
result.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:created_at)
|
result.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, :postdate)
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_widget
|
def default_widget
|
||||||
|
@ -58,10 +57,10 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
@data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
|
@data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
|
||||||
end
|
end
|
||||||
if @paginate
|
if @paginate
|
||||||
@data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
|
@data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit)
|
||||||
# @data = query_for_default_widget.limit(@data_limit).includes(@widget_image_field)
|
# @data = query_for_default_widget.limit(@data_limit).includes(@widget_image_field)
|
||||||
else
|
else
|
||||||
@data = query_for_default_widget.includes(@widget_image_field).desc(:created_at)
|
@data = query_for_default_widget.includes(@widget_image_field).limit(@data_limit)
|
||||||
# @data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at)
|
# @data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at)
|
||||||
end
|
end
|
||||||
case params[:type]
|
case params[:type]
|
||||||
|
|
Reference in New Issue