Added eval; site now shows clean dataset missing message instead of server error...
[sgn.git] / lib / SGN / Controller / Reports.pm
blob16119599340b72406cf289d002c337030ef3d6dd
2 package SGN::Controller::Reports;
4 use Moose;
5 use Data::Dumper;
6 use SGN::Model::Cvterm;
8 BEGIN { extends 'Catalyst::Controller' };
10 sub reports : Path('/reports') Args(0) {
11 my $self = shift;
12 my $c = shift;
14 $c->stash->{template} = '/reports/index.mas';
17 sub overview : Path('/reports/overview') Args(0) {
18 my $self = shift;
19 my $c = shift;
21 my $schema = $c->dbic_schema("Bio::Chado::Schema");
22 my $people_schema = $c->dbic_schema("CXGN::People::Schema");
24 my %stats;
26 # Number of Germplasms
27 # Number of Germplasm with Pedigree
28 # Number of Germplasms with phenotyping information
29 # Number of Germplasm with Genotyping information
30 # Number of Locations
31 # Number of users
32 # Number of traits
33 # Number of trails
34 # Number of images
35 # Number of Spectra data
36 # Number of plots
37 # Number of plants
38 # Number of tissue samples
39 # Number of genotyping plates
40 # Number of genotyping protocols
41 # Number of Crosses
42 # Number of seeds
43 # Number of Markers
44 # Number of Breeding programs
45 # Number of years
46 # Number of Phenotypes
48 # number of accessions
50 my $accession_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'accession', 'stock_property')->cvterm_id();
51 my $rs = $schema->resultset("Stock::Stock")->search( { type_id => $accession_type_id });
52 $stats{accession_count} = $rs->count();
54 my $female_parent_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'female_parent', 'stock_relationship');
55 my $accession_with_pedigrees = $schema->resultset("Stock::Stock")->search( { type_id => $accession_type_id }, { join => 'object', '+select' => 'object.type_id', '+as' => 'relationship_type_id' });
58 $c->stash->{template} = '/reports/overview.mas';