before_filter :offline_redirect, :only => [:create, :edit, :delete, :data, :api_create, :api_delete, :api_data]
around_filter :api_call_handle_error, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data]
- caches_action :list, :unless => :logged_in?, :layout => false
- caches_action :view, :layout => false
- caches_action :georss, :layout => true
- cache_sweeper :trace_sweeper, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete]
- cache_sweeper :tracetag_sweeper, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete]
-
# Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.).
# target_user - if set, specifies the user to fetch traces for. if not set will fetch all traces
def list
end
if params[:tag]
- @tag = params[:tag]
-
- files = Tracetag.where(:tag => params[:tag]).select(:gpx_id).all
-
- if files.length > 0
- @traces = @traces.where(:id => files.collect { |tt| tt.gpx_id })
- end
+ @traces = @traces.tagged(params[:tag])
end
@page = (params[:page] || 1).to_i
end
def georss
- traces = Trace.public
+ traces = Trace.public.visible
if params[:display_name]
traces = traces.joins(:user).where(:users => {:display_name => params[:display_name]})
end
if params[:tag]
- traces = traces.where("EXISTS (SELECT * FROM gpx_file_tags AS gft WHERE gft.gpx_id = gpx_files.id AND gft.tag = ?)", params[:tag])
+ traces = traces.tagged(params[:tag])
end
traces = traces.order("timestamp DESC")