]> iEval git - gruntmaster-data.git/commitdiff
Include problem/contest counts in user_list
authorMarius Gavrilescu <marius@ieval.ro>
Fri, 12 Dec 2014 13:17:37 +0000 (15:17 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Fri, 12 Dec 2014 13:17:37 +0000 (15:17 +0200)
lib/Gruntmaster/Data.pm

index 0b04b7b884ebb98e6a396005673971cd9ed0de1d..e8b5c73b5ed90becf07f8b3e8caa491062862722 100644 (file)
@@ -42,8 +42,13 @@ BEGIN {
 }
 
 sub user_list {
-       my $rs = $_[0]->users->search(undef, {order_by => 'name', columns => USER_PUBLIC_COLUMNS});
-       [ map { { $_->get_columns } } $rs->all ]
+       my $rs = $_[0]->users->search(undef, {columns => USER_PUBLIC_COLUMNS, prefetch => [qw/problem_statuses contest_statuses/]} );
+       [ sort { $b->{solved} <=> $a->{solved} or $b->{attempted} <=> $a->{attempted} }map {
+               my $solved    = $_->problem_statuses->count(solved => 1);
+               my $attempted = $_->problem_statuses->count(solved => 0);
+               my $contests  = $_->contest_statuses->count;
+               +{ $_->get_columns, solved => $solved, attempted => $attempted, contests => $contests }
+       } $rs->all ]
 }
 
 sub user_entry {
This page took 0.029359 seconds and 4 git commands to generate.