<commit_before>
use strict;

package SGN::Controller::ExcelScoreSheet;

use Moose;
use Spreadsheet::WriteExcel;
use File::Slurp qw | read_file |;
use File::Temp;
use Data::Dumper;
use CXGN::Trial::TrialLayout;

BEGIN { extends 'Catalyst::Controller'; }


sub excel_download_trial : Path('/barcode/trial_excel_download') Args(1) { 
    my $self = shift;
    my $c = shift;
    my $trial_id=shift;

    my $tl = CXGN::Trial::TrialLayout->new( { schema => $c->dbic_schema("Bio::Chado::Schema"), trial_id => $trial_id });

    my $trial_data = $tl->get_design();

    print STDERR Data::Dumper::Dumper($trial_data);
    
    



}


sub excel_download : Path('/barcode/excel_download/') Args(0) { 
    my $self  =shift;
    my $c = shift;
  
    my $operator = $c->req->param('operator');
    my $date     = $c->req->param('date');
    my $project  = $c->req->param('project');
    my $location = $c->req->param('location');
    my $lines    = $c->req->param('lines');
    my @cvterms = $c->req->param('cvterms');

    my $schema = $c->dbic_schema("Bio::Chado::Schema");

    my $project_row = $schema->resultset("Project::Project")->find($project);
    my $project_name = $project_row->name();
    my $project_desc = $project_row->description();


    $lines =~ s/\r//g;
    my @lines = split /\n/, $lines;

    my $plot_of = $schema->resultset("Cv::Cvterm")->find( { name => "plot_of" })->cvterm_id();
    print STDERR "PLOT_OF: $plot_of\n";
    
    my $plot_type = $schema->resultset("Cv::Cvterm")->find( { name=>"plot"})->cvterm_id();
    

    # check if all lines exist and bail out if not
    my @missing = ();
    my @not_plots = ();
    my @stock_rows = ();
    foreach my $s (@lines) { 
	my $stock_row = $schema->resultset("Stock::Stock")->find( { name=>$s });
	if (!$stock_row) {
	    print STDERR "Missing: $s\n";
	    push @missing, $s;
	}
	elsif ($stock_row->type_id != $plot_type) { 
	    push @not_plots, $s;
	}
	else { 
	    push @stock_rows, $stock_row;<commit_msg>minor tweak of DBIx::Class statement.<commit_after>
use strict;

package SGN::Controller::ExcelScoreSheet;

use Moose;
use Spreadsheet::WriteExcel;
use File::Slurp qw | read_file |;
use File::Temp;
use Data::Dumper;
use CXGN::Trial::TrialLayout;

BEGIN { extends 'Catalyst::Controller'; }


sub excel_download_trial : Path('/barcode/trial_excel_download') Args(1) { 
    my $self = shift;
    my $c = shift;
    my $trial_id=shift;

    my $tl = CXGN::Trial::TrialLayout->new( { schema => $c->dbic_schema("Bio::Chado::Schema"), trial_id => $trial_id });

    my $trial_data = $tl->get_design();

    print STDERR Data::Dumper::Dumper($trial_data);
    
    



}


sub excel_download : Path('/barcode/excel_download/') Args(0) { 
    my $self  =shift;
    my $c = shift;
  
    my $operator = $c->req->param('operator');
    my $date     = $c->req->param('date');
    my $project  = $c->req->param('project');
    my $location = $c->req->param('location');
    my $lines    = $c->req->param('lines');
    my @cvterms = $c->req->param('cvterms');

    my $schema = $c->dbic_schema("Bio::Chado::Schema");

    my $project_row = $schema->resultset("Project::Project")->find({ name => $project});
    my $project_name = $project_row->name();
    my $project_desc = $project_row->description();


    $lines =~ s/\r//g;
    my @lines = split /\n/, $lines;

    my $plot_of = $schema->resultset("Cv::Cvterm")->find( { name => "plot_of" })->cvterm_id();
    print STDERR "PLOT_OF: $plot_of\n";
    
    my $plot_type = $schema->resultset("Cv::Cvterm")->find( { name=>"plot"})->cvterm_id();
    

    # check if all lines exist and bail out if not
    my @missing = ();
    my @not_plots = ();
    my @stock_rows = ();
    foreach my $s (@lines) { 
	my $stock_row = $schema->resultset("Stock::Stock")->find( { name=>$s });
	if (!$stock_row) {
	    print STDERR "Missing: $s\n";
	    push @missing, $s;
	}
	elsif ($stock_row->type_id != $plot_type) { 
	    push @not_plots, $s;
	}
	else { 
	    push @stock_rows, $stock_row;
{'fraction_non_alphanumeric': 0.1964956195244055, 'fraction_numerical': 0.0010012515644555694, 'mean_word_length': 3.5050732807215335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3613839', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1450, 'n_words': 307}