don't use turbolinks on public channels list
This commit is contained in:
parent
fefab267c2
commit
435fe52e4a
@ -296,12 +296,17 @@ class ApplicationController < ActionController::Base
|
||||
# allow more past data if necessary
|
||||
get_old_data = (params[:results].present? || params[:start].present? || params[:days].present?) ? true : false
|
||||
|
||||
# set default start date
|
||||
# set default start and end dates
|
||||
start_date = (get_old_data) ? Time.parse('2010-01-01') : (Time.now - 1.day)
|
||||
end_date = Time.now
|
||||
start_date = (Time.now - params[:days].to_i.days) if params[:days]
|
||||
start_date = ActiveSupport::TimeZone[Time.zone.name].parse(params[:start]) if params[:start]
|
||||
end_date = ActiveSupport::TimeZone[Time.zone.name].parse(params[:end]) if params[:end]
|
||||
|
||||
# set new start and end dates if necessary
|
||||
start_date = (Time.now - params[:days].to_i.days) if params[:days].present?
|
||||
start_date = (Time.now - params[:minutes].to_i.minutes) if params[:minutes].present?
|
||||
start_date = ActiveSupport::TimeZone[Time.zone.name].parse(params[:start]) if params[:start].present?
|
||||
end_date = ActiveSupport::TimeZone[Time.zone.name].parse(params[:end]) if params[:end].present?
|
||||
|
||||
# set the date range
|
||||
date_range = (start_date..end_date)
|
||||
# only get a maximum of 30 days worth of data
|
||||
date_range = (end_date - 30.days..end_date) if ((end_date - start_date) > 30.days and !get_old_data)
|
||||
|
@ -20,6 +20,15 @@ class FeedFactory < ApplicationController
|
||||
# attributes that can be read
|
||||
attr_reader :feeds, :daily_feeds, :limit, :use_daily_feed, :feed_select_options, :cache_feeds, :channel
|
||||
|
||||
# range for entry_ids
|
||||
def entry_id_range
|
||||
# set start and end id
|
||||
start_id = @options[:start_entry_id].present? ? @options[:start_entry_id].to_i : 1
|
||||
end_id = @options[:end_entry_id].present? ? @options[:end_entry_id].to_i : @channel.last_entry_id
|
||||
# return the range
|
||||
return start_id..end_id
|
||||
end
|
||||
|
||||
# calculate the limit that should be used
|
||||
def calculate_limit
|
||||
limit = 100
|
||||
@ -88,10 +97,18 @@ class FeedFactory < ApplicationController
|
||||
|
||||
# get feeds
|
||||
def get_feeds
|
||||
# get feeds based on entry ids
|
||||
if @options[:start_entry_id].present? || @options[:end_entry_id].present?
|
||||
@feeds = Feed.from("feeds FORCE INDEX (index_feeds_on_channel_id_and_entry_id)")
|
||||
.where(:channel_id => @channel.id, :entry_id => entry_id_range)
|
||||
# get feed based on conditions
|
||||
@feeds = Feed.from("feeds FORCE INDEX (index_feeds_on_channel_id_and_created_at)")
|
||||
.where(:channel_id => @channel.id, :created_at => @date_range)
|
||||
.select(@feed_select_options)
|
||||
else
|
||||
@feeds = Feed.from("feeds FORCE INDEX (index_feeds_on_channel_id_and_created_at)")
|
||||
.where(:channel_id => @channel.id, :created_at => @date_range)
|
||||
end
|
||||
|
||||
# apply filters and load the feeds
|
||||
@feeds = @feeds.select(@feed_select_options)
|
||||
.order('created_at desc')
|
||||
.limit(@limit)
|
||||
.load
|
||||
|
@ -1,6 +1,6 @@
|
||||
<% @channels.each do |channel| %>
|
||||
|
||||
<div class="col-md-4 col-sm-6 col-xs-12">
|
||||
<div class="col-md-4 col-sm-6 col-xs-12" data-no-turbolink>
|
||||
<div class="panel panel-primary">
|
||||
|
||||
<div class="panel-heading">
|
||||
|
Loading…
Reference in New Issue
Block a user