]> iEval git - gruntmaster-data.git/blobdiff - lib/Gruntmaster/Data.pm
Do not show users with no jobs in user_list
[gruntmaster-data.git] / lib / Gruntmaster / Data.pm
index bcb3571dbaab1e2845671e9d82dcbe94f1bc3a0a..d9f61aa172afab7f8c484650d7c9423e93b9deb3 100644 (file)
@@ -25,6 +25,7 @@ use HTTP::Tiny;
 use PerlX::Maybe qw/maybe/;
 use Sub::Name qw/subname/;
 
+use constant CONTEST_PUBLIC_COLUMNS => [qw/id name description start stop owner/];
 use constant PROBLEM_PUBLIC_COLUMNS => [qw/id author writer level name owner private timeout olimit value/];
 use constant USER_PUBLIC_COLUMNS => [qw/id admin name town university country level/];
 use constant JOBS_PER_PAGE => 10;
@@ -55,13 +56,14 @@ sub user_list {
        }
        $contests{$_->rawowner}++ for $self->contest_statuses->all;
 
-       [ sort { $b->{solved} <=> $a->{solved} or $b->{attempted} <=> $a->{attempted} } map { ## no critic (ProhibitReverseSort)
-               my $id = $_->id;
-               +{ $_->get_columns,
-                  solved => ($solved{$id} // 0),
-                  attempted => ($attempted{$id} // 0),
-                  contests => ($contests{$id} // 0) }
-       } $rs->all ]
+       [ sort { $b->{solved} <=> $a->{solved} or $b->{attempted} <=> $a->{attempted} } ## no critic (ProhibitReverseSort)
+               grep { $_->{solved} || $_->{attempted} } map {
+                       my $id = $_->id;
+                       +{ $_->get_columns,
+                          solved => ($solved{$id} // 0),
+                          attempted => ($attempted{$id} // 0),
+                          contests => ($contests{$id} // 0) }
+               } $rs->all ]
 }
 
 sub user_entry {
@@ -118,7 +120,7 @@ sub problem_entry {
 
 sub contest_list {
        my ($self, %args) = @_;
-       my $rs = $self->contests->search(undef, {order_by => {-desc => 'start'}, prefetch => 'owner'});
+       my $rs = $self->contests->search(undef, {columns => CONTEST_PUBLIC_COLUMNS, order_by => {-desc => 'start'}, prefetch => 'owner'});
        $rs = $rs->search({owner => $args{owner}}) if $args{owner};
        my %params;
        for ($rs->all) {
@@ -131,7 +133,7 @@ sub contest_list {
 
 sub contest_entry {
        my ($self, $id) = @_;
-       my $ct = $self->contest($id);
+       my $ct = $self->contests->find($id,{columns => CONTEST_PUBLIC_COLUMNS});
        +{ $ct->get_columns, started => !$ct->is_pending, finished => $ct->is_finished, owner_name => $ct->owner->name }
 }
 
This page took 0.025211 seconds and 4 git commands to generate.