From d4c5bf27d83bcf826e66bf897ea6ffc790217da1 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 4 Jan 2015 17:26:01 +0200 Subject: [PATCH] Add a "private" argument to problem_ and job_list --- lib/Gruntmaster/Data.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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; -- 2.39.2