From: Marius Gavrilescu Date: Thu, 18 Jun 2015 14:30:07 +0000 (+0300) Subject: Remove _full methods X-Git-Tag: 5999.000_014~16 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=cab36bc417a7d8723aeef55269adc8f2425d8e99;hp=b69781c1e813454383f9890792d3c2b35d747bd4;p=gruntmaster-data.git Remove _full methods --- diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 4bd7513..559ae62 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -4,7 +4,7 @@ use warnings; use parent qw/Exporter/; our $VERSION = '5999.000_013'; -our @EXPORT = qw/purge db user_list user_entry problem_list problem_entry problem_full contest_list contest_entry contest_full contest_has_problem job_list job_entry job_full create_job standings update_status rerun_job take_job finish_job/; ## no critic (ProhibitAutomaticExportation) +our @EXPORT = qw/purge db user_list user_entry problem_list problem_entry contest_list contest_entry contest_has_problem job_list job_entry create_job standings update_status rerun_job take_job finish_job/; ## no critic (ProhibitAutomaticExportation) use JSON::MaybeXS qw/decode_json/; use HTTP::Tiny; @@ -27,18 +27,15 @@ my %statements = ( contest_list_sth => 'SELECT * FROM contest_entry', contest_entry_sth => 'SELECT * FROM contest_entry WHERE id = ?', - contest_full_sth => 'SELECT * FROM contests WHERE id = ?', contest_problems_sth => 'SELECT problem FROM contest_problems JOIN problems pb ON problem=pb.id WHERE contest = ? ORDER BY pb.value', contest_has_problem_sth => 'SELECT EXISTS(SELECT 1 FROM contest_problems WHERE contest = ? AND problem = ?)', opens_sth => 'SELECT problem,owner,time FROM opens WHERE contest = ?', problem_entry_sth => 'SELECT ' . (join ',', @{PROBLEM_PUBLIC_COLUMNS()}, 'statement', 'solution') . ' FROM problems WHERE id = ?', - problem_full_sth => 'SELECT * FROM problems WHERE id = ?', limits_sth => 'SELECT format,timeout FROM limits WHERE problem = ?', problem_values_sth => 'SELECT id,value FROM problems', job_entry_sth => 'SELECT * FROM job_entry WHERE id = ?', - job_full_sth => 'SELECT * FROM jobs WHERE id = ?', rerun_job_sth => 'UPDATE jobs SET daemon=NULL,result=-2,result_text=NULL,results=NULL,errors=NULL WHERE id = ?', take_job_sth => 'UPDATE jobs SET daemon=? WHERE id = (SELECT id FROM jobs WHERE daemon IS NULL LIMIT 1 FOR UPDATE) RETURNING id', @@ -130,14 +127,10 @@ sub problem_entry { $ret } -sub problem_full { scalar query(problem_full_sth => $_[0])->hash } - sub contest_list { add_names query('contest_list_sth')->hashes } sub contest_entry { add_names query(contest_entry_sth => $_[0])->hash } -sub contest_full { scalar query(contest_full_sth => $_[0])->hash } - sub contest_has_problem { query('contest_has_problem_sth', @_[0, 1])->flat } sub job_list { @@ -170,8 +163,6 @@ sub job_entry { $ret } -sub job_full { scalar query(job_full_sth => $_[0])->hash } - sub create_job { my (%args) = @_; $db->update('users', {lastjob => time}, {id => $args{owner}}); @@ -266,7 +257,7 @@ sub rerun_job { sub take_job { my ($daemon) = @_; my $id = query(take_job_sth => $daemon)->list; - return $id ? job_full $id : undef; + return $id ? db->select(jobs => '*', {id => $id})->hash : undef; } sub finish_job { diff --git a/t/Gruntmaster-Data.t b/t/Gruntmaster-Data.t index 0b325a3..38c2330 100644 --- a/t/Gruntmaster-Data.t +++ b/t/Gruntmaster-Data.t @@ -10,7 +10,7 @@ BEGIN { eval { Gruntmaster::Data::init 'dbi:Pg:dbname=gmtest'; 1; } or plan skip_all => 'Cannot connect to test database. Create it by running createdb gmtest before running this test. '. "Error: $@"; - plan tests => 35; + plan tests => 33; } note 'Setting up test database'; @@ -67,9 +67,6 @@ cmp_bag ids, [qw/pc rc fc/], 'contest_list'; $x = contest_entry 'fc'; cmp_deeply $x, {id => 'fc', name => 'Finished contest', start => ignore, stop => ignore, owner => 'MGV', owner_name => undef, finished => bool (1), started => bool (1), description => undef}, 'contest_entry fc'; -$x = contest_full 'fc'; -ok exists $x->{editorial}, 'contest_full fc has editorial'; - ok contest_has_problem('rc', 'rca'), 'contest rc has problem rca'; ok contest_has_problem('rc', 'arc'), 'contest rc does not have problem arc'; @@ -104,9 +101,6 @@ is_deeply $x->{results}, [], 'job_entry results'; $x = job_entry 7; ok !defined $x->{result}, 'job_entry 7 has NULL result'; -$x = job_full 1; -ok exists $x->{source}, 'job_full has source'; - $x = standings 'fc'; is_deeply $x, { problems => [[fca => 'FC problem A']],