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;
}
$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 {
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) {
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 }
}