From: Marius Gavrilescu Date: Sun, 4 Jan 2015 15:26:01 +0000 (+0200) Subject: Add a "private" argument to problem_ and job_list X-Git-Tag: 5999.000_014~99 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=d4c5bf27d83bcf826e66bf897ea6ffc790217da1;p=gruntmaster-data.git Add a "private" argument to problem_ and job_list --- diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 984035f..fabdbec 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -75,7 +75,7 @@ sub user_entry { sub problem_list { my ($self, %args) = @_; my $rs = $self->problems->search(undef, {order_by => 'me.name', columns => PROBLEM_PUBLIC_COLUMNS, prefetch => 'owner'}); - $rs = $rs->search({-or => ['contest_problems.contest' => undef, 'contest.stop' => {'<=', time}], 'me.private' => 0}, {join => {'contest_problems' => 'contest'}, distinct => 1}) unless $args{contest}; + $rs = $rs->search({-or => ['contest_problems.contest' => undef, 'contest.stop' => {'<=', time}], 'me.private' => 0}, {join => {'contest_problems' => 'contest'}, distinct => 1}) unless $args{contest} || $args{private}; $rs = $rs->search({'contest_problems.contest' => $args{contest}}, {join => 'contest_problems'}) if $args{contest}; $rs = $rs->search({'me.owner' => $args{owner}}) if $args{owner}; my %params; @@ -127,10 +127,11 @@ sub contest_entry { sub job_list { my ($self, %args) = @_; $args{page} //= 1; - my $rs = $self->jobs->search({'me.private' => 0}, {order_by => {-desc => 'me.id'}, prefetch => ['problem', 'owner'], rows => JOBS_PER_PAGE, page => $args{page}}); - $rs = $rs->search({'me.owner' => $args{owner}}) if $args{owner}; - $rs = $rs->search({contest => $args{contest}}) if $args{contest}; - $rs = $rs->search({problem => $args{problem}}) if $args{problem}; + my $rs = $self->jobs->search(undef, {order_by => {-desc => 'me.id'}, prefetch => ['problem', 'owner'], rows => JOBS_PER_PAGE, page => $args{page}}); + $rs = $rs->search({'me.private'=> 0}) unless $args{private}; + $rs = $rs->search({'me.owner' => $args{owner}}) if $args{owner}; + $rs = $rs->search({contest => $args{contest}}) if $args{contest}; + $rs = $rs->search({problem => $args{problem}}) if $args{problem}; return { log => [map { my %params = $_->get_columns;