Make contest_* only return public columns (all of them but editorial)
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 14 Feb 2015 09:07:15 +0000 (11:07 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 14 Feb 2015 09:07:15 +0000 (11:07 +0200)
lib/Gruntmaster/Data.pm

index bcb3571dbaab1e2845671e9d82dcbe94f1bc3a0a..28b520a69e5b7031e276743ec5f4b2d8754441ed 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;
@@ -118,7 +119,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 +132,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.011148 seconds and 4 git commands to generate.