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 @@ -217,14 +217,37 @@ def multiple_login + #user with multiple IP raw = Submission.joins(:user).joins(:problem).where("problems.available != 0").group("login,ip_address").order(:login) last,count = 0,0 - @multiple = [] + first = 0 + @users = [] raw.each do |r| if last != r.user.login count = 1 + last = r.user.login + first = r else - @multiple << r + @users << first if count == 1 + @users << r + count += 1 + end + end + + #IP with multiple user + raw = Submission.joins(:user).joins(:problem).where("problems.available != 0").group("login,ip_address").order(:ip_address) + last,count = 0,0 + first = 0 + @ip = [] + raw.each do |r| + if last != r.ip_address + count = 1 + last = r.ip_address + first = r + else + @ip << first if count == 1 + @ip << r + count += 1 end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,7 +13,7 @@ append_to menu_items, '[Problems]', 'problems', 'index' append_to menu_items, '[Users]', 'user_admin', 'index' append_to menu_items, '[Results]', 'user_admin', 'user_stat' - append_to menu_items, '[Report]', 'report', 'login_stat' + append_to menu_items, '[Report]', 'report', 'multiple_login' append_to menu_items, '[Graders]', 'graders', 'list' append_to menu_items, '[Contests]', 'contest_management', 'index' append_to menu_items, '[Sites]', 'sites', 'index' diff --git a/app/views/problems/stat.html.haml b/app/views/problems/stat.html.haml --- a/app/views/problems/stat.html.haml +++ b/app/views/problems/stat.html.haml @@ -34,6 +34,7 @@ %th Submitted_at %th Points %th comment + %th IP %tbody - row_odd,curr = true,'' - @submissions.each do |sub| @@ -46,6 +47,7 @@ %td= time_ago_in_words(sub.submitted_at) + " ago" %td= sub.points %td.fix-width= sub.grader_comment + %td= sub.ip_address - else No submission diff --git a/app/views/report/multiple_login.html.haml b/app/views/report/multiple_login.html.haml --- a/app/views/report/multiple_login.html.haml +++ b/app/views/report/multiple_login.html.haml @@ -6,6 +6,9 @@ =render partial: 'report_menu' +Checking for all submissions with the currently available problem + +%h2 Users with Multiple IP %table.tablesorter-cafe#my_table %thead %tr @@ -13,8 +16,22 @@ %th full name %th IP %tbody - - @multiple.each do |l| + - @users.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= link_to l.user.login, controller: 'users', action: 'profile', id: l[:id] + %td= l.user.full_name %td= l[:ip_address] + +%h2 IP with multiple users +%table.tablesorter-cafe#my_table + %thead + %tr + %th IP + %th login + %th full name + %tbody + - @ip.each do |l| + %tr{class: cycle('info-even','info-odd')} + %td= l[:ip_address] + %td= link_to l.user.login, controller: 'users', action: 'profile', id: l[:id] + %td= l.user.full_name