# HG changeset patch # User Nattee Niparnan # Date 2022-02-10 16:47:16 # Node ID d7fa5bf1aeba317b6f1e66f5aa478d92e05b58a6 # Parent 9a927c70d5aa4c7013c7fc6f8bc24ade39697cc5 fig bugs in login report diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -72,8 +72,6 @@ value = SecureRandom.uuid cookies.encrypted[:uuid] = { value: value, expires: 20.year } end - puts "encrypt " + cookies.encrypted[:uuid] - puts cookies[:uuid] end protected diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -119,8 +119,9 @@ md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) rescue - @since_time = DateTime.new(1000,1,1) + @since_time = Time.zone.now end + puts @since_time begin md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) @until_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) @@ -143,12 +144,14 @@ x = Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", user[0],@since_time,@until_time) .pluck(:ip_address).uniq + puts user[4] + puts user[5] @users << { id: user[0], login: user[1], full_name: user[2], count: user[3], - min: user[4], - max: user[5], + min: user[4].in_time_zone, + max: user[5].in_time_zone, ip: x } end @@ -162,7 +165,7 @@ md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) rescue - @since_time = DateTime.new(1000,1,1) + @since_time = Time.zone.now end begin md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)