6 has
'dbh' => (isa
=> 'Ref', is
=> 'rw');
8 # retrieve all trials grouped by trial type
12 my $q = "SELECT cvterm.name, count(*) from projectprop join cvterm on(type_id=cvterm_id) JOIN cv USING (cv_id) WHERE cv_id=(SELECT cv_id FROM cv WHERE name='project_type') GROUP BY cvterm.name ORDER BY count(*) desc";
13 my $h = $self->dbh->prepare($q);
15 return $h->fetchall_arrayref();
18 # retrieve all trials grouped by breeding programs
20 sub trials_by_breeding_program
{
22 my $q = "select project.name, count(*) from project join project_relationship on (project.project_id=project_relationship.object_project_id) join project as trial on(subject_project_id=trial.project_id) join projectprop on(project.project_id = projectprop.project_id) join cvterm on (projectprop.type_id=cvterm.cvterm_id) join projectprop as trialprop on(trial.project_id = trialprop.project_id) join cvterm as trialcvterm on(trialprop.type_id=trialcvterm.cvterm_id) where cvterm.name='breeding_program' and trialcvterm.name in (SELECT cvterm.name FROM cvterm join cv using(cv_id) WHERE cv.name='project_type') group by project.name order by count(*) desc";
23 my $h = $self->dbh->prepare($q);
25 return $h->fetchall_arrayref();
28 # retrieve all the traits measured with counts
32 my $q = "select cvterm.name, count(*) from phenotype join cvterm on (observable_id=cvterm_id) group by cvterm.name order by count(*) desc";
33 my $h = $self->dbh->prepare($q);
35 return $h->fetchall_arrayref();
40 my $q = "SELECT cvterm.name, count(*) FROM stock join cvterm on(type_id=cvterm_id) GROUP BY cvterm.name ORDER BY count(*) desc";
41 my $h = $self->dbh->prepare($q);
43 return $h->fetchall_arrayref();
48 my $q = "select count(*) from ";
56 foreach my $week (0..51) {
58 my $previous_days = ($week + 1) * 7;
59 my $q = "SELECT count(*) FROM nd_experiment WHERE create_date > (now() - INTERVAL '$previous_days DAYS') and create_date < (now() - INTERVAL '$days DAYS')";
60 my $h = $self->dbh()->prepare($q);
62 my ($count) = $h->fetchrow_array();
64 print STDERR
"Activity in week $week = $count\n";
66 push @counts, { letter
=> $week, frequency
=> $count };