Class: LogviewsController

Inherits:
ApplicationController show all
Defined in:
lib/six-updater-web/app/controllers/logviews_controller.rb

Instance Method Summary collapse

Methods included from Six::Import::Controller::ClassMethods

#copy, #six_local_auto_login

Methods inherited from ActionController::Base

#active_scaffold_render_secure_download, #assign_names_with_active_scaffold, #render_with_active_scaffold, #search_generic_view_paths?

Instance Method Details

#conditions_for_collectionObject



47
48
49
50
# File 'lib/six-updater-web/app/controllers/logviews_controller.rb', line 47

def conditions_for_collection
  s = Logsession.find(:last)
  ['logsession_id = (?)', s] if s
end

#updObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/six-updater-web/app/controllers/logviews_controller.rb', line 12

def upd
  s = Log.find(:last, :select => "id,updated_at")
  s = Log.new unless s
  logger.debug "Latest entry: #{s.id}"

  #session[:logentry] = 0 unless session[:logentry]
  # Cache'll loop :D
#    cached = Rails.cache.read('logs_last')
#    if cached
#      s = cached.to_i
#      logger.debug "cached entry #{s}"
#    else
#      Rails.cache.write('logs_last', s)
#    end

  a = false
  if session[:logentry] && session[:logupdated]
    logger.debug "Session entry #{session[:logentry]} - #{session[:logupdated]}"
    if s.id != session[:logentry] || s.updated_at != session[:logupdated]            
      session[:logentry] = s.id
      session[:logupdated] = s.updated_at
      logger.debug "New session entry #{session[:logentry]} - #{session[:logupdated]}"
      a = true
    end
  else
    session[:logentry] = s.id
    session[:logupdated] = s.updated_at
    logger.debug "New session entry #{session[:logentry]} - #{session[:logupdated]}"
    a = true
  end

  # TODO: Only refresh activescaffold instead?
  render :nothing => true unless a
end