X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData.pm;h=627fb8b26796ae2047ed813f114f6e0989def420;hb=ebf0770ac0ad58f91add71acecf8f80ed2816e53;hp=0b04b7b884ebb98e6a396005673971cd9ed0de1d;hpb=751c70b56c8cbd4850821a2ecce774a01a7bd165;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 0b04b7b..627fb8b 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -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 { ## no critic (ProhibitReverseSort) + 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 {