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 @@ -38,7 +38,11 @@ .minimum(:created_at), max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", user.id,@since_time,@until_time) - .maximum(:created_at) + .maximum(:created_at), + ip: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", + user.id,@since_time,@until_time) + .select(:ip_address).uniq + } end end diff --git a/app/views/report/login_stat.html.haml b/app/views/report/login_stat.html.haml --- a/app/views/report/login_stat.html.haml +++ b/app/views/report/login_stat.html.haml @@ -22,6 +22,7 @@ %th login count %th earliest %th latest + %th IP %tbody - @logins.each do |l| %tr{class: cycle('info-even','info-odd')} @@ -29,4 +30,7 @@ %td= l[:full_name] %td= l[:count] %td= l[:min] ? l[:min].in_time_zone.strftime('%Y-%m-%d %H:%M') : '' - %td= l[:max] ? "#{l[:max].in_time_zone.strftime('%Y-%m-%d %H:%M')} (#{time_ago_in_words(l[:max].in_time_zone)} ago)" : '' + %td= l[:max] ? "#{l[:max].in_time_zone.strftime('%Y-%m-%d %H:%M.%S')} (#{time_ago_in_words(l[:max].in_time_zone)} ago)" : '' + %td + - l[:ip].each do |ip| + #{ip.ip_address}