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 @@ -215,4 +215,18 @@ @struggle = @struggle[0..50] end + + def multiple_login + raw = Submission.joins(:user).joins(:problem).where("problems.available != 0").group("login,ip_address").order(:login) + last,count = 0,0 + @multiple = [] + raw.each do |r| + if last != r.user.login + count = 1 + else + @multiple << r + end + end + end + end diff --git a/app/views/report/_report_menu.html.haml b/app/views/report/_report_menu.html.haml --- a/app/views/report/_report_menu.html.haml +++ b/app/views/report/_report_menu.html.haml @@ -5,3 +5,4 @@ = link_to '[Hall of Fame]', :action => 'problem_hof' = link_to '[Struggle]', :action => 'stuck' = link_to '[Login]', :action => 'login_stat' + = link_to '[Multiple Login]', :action => 'multiple_login' diff --git a/app/views/report/multiple_login.html.haml b/app/views/report/multiple_login.html.haml new file mode 100644 --- /dev/null +++ b/app/views/report/multiple_login.html.haml @@ -0,0 +1,20 @@ +- content_for :header do + = stylesheet_link_tag 'tablesorter-theme.cafe' + = javascript_include_tag 'local_jquery' + +%h1 Login status + +=render partial: 'report_menu' + +%table.tablesorter-cafe#my_table + %thead + %tr + %th login + %th full name + %th IP + %tbody + - @multiple.each do |l| + %tr{class: cycle('info-even','info-odd')} + %td= link_to l[:login], controller: 'users', action: 'profile', id: l[:id] + %td= l[:full_name] + %td= l[:ip_address]