Class: Fastentry::DashboardController

Inherits:
ApplicationController show all
Defined in:
app/controllers/fastentry/dashboard_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/fastentry/dashboard_controller.rb', line 5

def index
  @keys = Rails.cache.instance_variable_get(:@data).keys

  if params[:query].present?
    @keys = @keys.select { |c| c.include?(params[:query]) }
  end

  @number_of_pages = (@keys.count / @per_page.to_f).ceil

  @keys = @keys[@offset, @per_page] || []

  @cached = []
  @keys.each do |key|
    expiration_date = Rails.cache.send(:read_entry, key, {}).expires_at
    @cached << {
      cache_key: key,
      cache_value: Rails.cache.read(key.to_s),
      expiration: (Time.at(expiration_date) if expiration_date.present?)
    }
  end
end