- my $rs = $_[0]->users->search(undef, {order_by => 'name', columns => USER_PUBLIC_COLUMNS});
- [ map { { $_->get_columns } } $rs->all ]
+ my ($self) = @_;
+ my $rs = $self->users->search(undef, {columns => USER_PUBLIC_COLUMNS} );
+ my (%solved, %attempted, %contests);
+
+ for my $row ($self->problem_statuses->all) {
+ $solved {$row->rawowner}++ if $row->solved;
+ $attempted{$row->rawowner}++ unless $row->solved;
+ }
+ $contests{$_->rawowner}++ for $self->contest_statuses->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 ]