From 56b57d73b8df81a626d5d734c4678b1a14ae8d4a Mon Sep 17 00:00:00 2001 From: titima15 Date: Tue, 17 May 2022 00:57:08 +0000 Subject: [PATCH] added links for female and male parents --- lib/SGN/Controller/AJAX/Search/Cross.pm | 22 +++++++++++----------- mason/search/cross.mas | 2 +- mason/search/cross/parent_search.mas | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/SGN/Controller/AJAX/Search/Cross.pm b/lib/SGN/Controller/AJAX/Search/Cross.pm index a612a9d99..02bb7cfd6 100644 --- a/lib/SGN/Controller/AJAX/Search/Cross.pm +++ b/lib/SGN/Controller/AJAX/Search/Cross.pm @@ -137,27 +137,26 @@ sub search_common_parents : Path('/ajax/search/common_parents') Args(0) { my $accession_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'accession', 'stock_type')->cvterm_id(); - my @results; - foreach my $name (@accession_names) { - my $accession_rs = $schema->resultset("Stock::Stock")->find ({ 'uniquename' => $name, 'type_id' => $accession_type_id }); + my %result_hash; + foreach my $accession_name (@accession_names) { + my $accession_rs = $schema->resultset("Stock::Stock")->find ({ 'uniquename' => $accession_name, 'type_id' => $accession_type_id }); my $accession_id = $accession_rs->stock_id(); my $stock = CXGN::Stock->new({schema => $schema, stock_id=>$accession_id}); my $parents = $stock->get_parents(); my $female_parent = $parents->{'mother'}; my $male_parent = $parents->{'father'}; - push @results, [$female_parent, $male_parent, $name]; - } - - my %result_hash; - foreach my $each_set (@results) { - $result_hash{$each_set->[0]}{$each_set->[1]}{$each_set->[2]}++; + $result_hash{$female_parent}{$male_parent}{$accession_name}++; } my @formatted_results; foreach my $female (keys %result_hash) { + my $female_rs = $schema->resultset("Stock::Stock")->find ({ 'uniquename' => $female, 'type_id' => $accession_type_id }); + my $female_id = $female_rs->stock_id(); my $female_ref = $result_hash{$female}; my %female_hash = %{$female_ref}; foreach my $male (keys %female_hash) { + my $male_rs = $schema->resultset("Stock::Stock")->find ({ 'uniquename' => $male, 'type_id' => $accession_type_id }); + my $male_id = $male_rs->stock_id(); my @progenies = (); my $progenies_string; my $male_ref = $female_hash{$male}; @@ -168,16 +167,17 @@ sub search_common_parents : Path('/ajax/search/common_parents') Args(0) { my $number_of_accessions = scalar @progenies; my @sort_progenies = sort @progenies; $progenies_string = join("
", @sort_progenies); -# push @formatted_results, [$female, $male, $number_of_accessions, $progenies_string] push @formatted_results, { female_name => $female, + female_id => $female_id, male_name => $male, + male_id => $male_id, no_of_accessions => $number_of_accessions, progenies => $progenies_string }; } } - print STDERR "FORMATTED RESULTS =".Dumper(\@formatted_results)."\n"; + $c->stash->{rest}={ data=> \@formatted_results}; } diff --git a/mason/search/cross.mas b/mason/search/cross.mas index 2bef37e41..24b58e129 100644 --- a/mason/search/cross.mas +++ b/mason/search/cross.mas @@ -10,4 +10,4 @@ <& /page/detail_page_2_col_section.mas, info_section_collapsed => 1, info_section_title => "

Search Progenies

", info_section_subtitle => 'Search progenies of female or male parents.', icon_class => "glyphicon glyphicon-random", info_section_id => "progeny_search_section" &> <& /page/detail_page_2_col_section.mas, info_section_collapsed => 1, info_section_title => "

Search Crosses

", info_section_subtitle => 'Search cross details of female or male parents.', icon_class => "glyphicon glyphicon-move", info_section_id => "cross_search_section" &> -<& /page/detail_page_2_col_section.mas, info_section_collapsed => 1, info_section_title => "

Search Parents

", info_section_subtitle => 'Search parents based on a list of accessions.', icon_class => "glyphicon glyphicon-menu-up", info_section_id => "parent_search_section" &> +<& /page/detail_page_2_col_section.mas, info_section_collapsed => 1, info_section_title => "

Search Parents

", info_section_subtitle => 'Search common parents by using a list of accessions.', icon_class => "glyphicon glyphicon-menu-up", info_section_id => "parent_search_section" &> diff --git a/mason/search/cross/parent_search.mas b/mason/search/cross/parent_search.mas index ec6a12ba7..3a2e1cf68 100644 --- a/mason/search/cross/parent_search.mas +++ b/mason/search/cross/parent_search.mas @@ -63,11 +63,13 @@ jQuery(document).ready(function (){ columns: [ { title: "Female Parent", - data: "female_name", + data: null, + render: function(data, type, row){return ""+row.female_name+"";} }, { title: "Male Parent", - data: "male_name", + data: null, + render: function(data, type, row){return ""+row.male_name+"";} }, { title: "Number of Accessions", @@ -78,9 +80,7 @@ jQuery(document).ready(function (){ data: "progenies", }, ], - }); - }); }); -- 2.11.4.GIT