Class: GtfsEngine::DataSetsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/gtfs_engine/data_sets_controller.rb

Instance Method Summary collapse

Methods included from Concerns::Controllers::DataAccess

#data, #data_cache, #param_is_data_set_name?

Instance Method Details

#indexObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/gtfs_engine/data_sets_controller.rb', line 17

def index
  expires_in 3.hours

  @data_sets = Rails.cache.fetch('data_sets_index') do
    {}.tap do |sets|
      DataSet.order(:created_at).each do |set|
        (sets[set.name] ||= []) << set
      end
    end
  end

  dates = @data_sets.values.flatten.collect &:created_at
  if stale? last_modified: dates.max, public: true
    respond_with @data_sets
  end
end

#showObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/gtfs_engine/data_sets_controller.rb', line 34

def show
  expires_in 2.hours

  @data_set = data :id

  # Set location if the given id is a data-source name and not an ID
  if param_is_data_set_name? :id
    respond_with @data_set, location: data_set_url(@data_set)
  else
    respond_with @data_set
  end
end