Commit 5e0541b6 authored by Keith Jolley's avatar Keith Jolley

Add classification groups to the config check page.

parent 7b8a0ce4
......@@ -38,6 +38,7 @@ sub print_content {
if ( $self->{'system'}->{'dbtype'} eq 'isolates' ) {
$self->_check_locus_databases;
$self->_check_scheme_databases;
$self->_check_classification_scheme_databases;
} else {
$self->_check_client_databases;
}
......@@ -222,6 +223,61 @@ sub _check_scheme_databases {
return;
}
sub _check_classification_scheme_databases {
my ($self) = @_;
say q(<div class="box resultstable">);
say q(<h2>Classification scheme databases</h2>);
my $cschemes =
$self->{'datastore'}
->run_query( 'SELECT id FROM classification_schemes ORDER BY id', undef, { fetch => 'col_arrayref' } );
my $td = 1;
if (@$cschemes) {
say q(<div class="scrollable"><table class="resultstable"><tr><th>Classification scheme</th>)
. q(<th>Scheme</th><th>Database</th><th>Host</th><th>Port</th><th>Table</th><th>Database accessible</th>)
. q(<th>Seqdef classification scheme id</th><th>Classification data</th></tr>);
foreach my $cscheme_id (@$cschemes) {
my $cscheme_info = $self->{'datastore'}->get_classification_scheme_info($cscheme_id);
my $scheme_info = $self->{'datastore'}->get_scheme_info( $cscheme_info->{'scheme_id'} );
$cscheme_info->{'name'} =~ s/&/&amp;/gx;
$scheme_info->{'description'} =~ s/&/&amp;/gx;
print qq(<tr class="td$td"><td>$cscheme_info->{'id'}: $cscheme_info->{'name'}</td><td>)
. ("$scheme_info->{'id'}: $scheme_info->{'description'}")
. q(</td><td>)
. ( $scheme_info->{'dbase_name'} // q() )
. q(</td><td>)
. ( $scheme_info->{'dbase_host'} // $self->{'system'}->{'host'} )
. q(</td><td>)
. ( $scheme_info->{'dbase_port'} // $self->{'system'}->{'port'} )
. q(</td><td>)
. ( $scheme_info->{'dbase_table'} // q() )
. q(</td><td>);
if ( $self->{'datastore'}->get_classification_scheme($cscheme_id)->get_db ) {
print q(<span class="statusgood fa fa-check"></span>);
} else {
print q(<span class="statusbad fa fa-times"></span>);
}
print qq(</td><td>$cscheme_info->{'seqdef_cscheme_id'}</td><td>);
my $seqdef_db = $self->{'datastore'}->get_scheme( $cscheme_info->{'scheme_id'} )->get_db;
my $exists = $self->{'datastore'}->run_query(
'SELECT EXISTS(SELECT * FROM classification_group_profiles WHERE cg_scheme_id=?)',
$cscheme_info->{'seqdef_cscheme_id'},
{ db => $seqdef_db }
);
if ($exists) {
print q(<span class="statusgood fa fa-check"></span>);
} else {
print q(<span class="statusbad fa fa-times"></span>);
}
my $classification_data = say q(</td></tr>);
$td = $td == 1 ? 2 : 1;
}
say q(</table></div></div>);
} else {
say q(<p>No schemes with databases defined.</p>);
}
return;
}
sub _check_client_databases {
my ($self) = @_;
my $client_dbs =
......
......@@ -504,21 +504,25 @@ sub _get_classification_group_data {
foreach my $group_id (@$groups) {
my $isolate_count = $self->{'datastore'}->run_query(
"SELECT COUNT(*) FROM $view WHERE $view.id IN (SELECT id FROM $scheme_table WHERE $pk IN "
. "(SELECT profile_id FROM $cscheme_table WHERE group_id=?)) AND new_version IS NULL",
. "(SELECT profile_id FROM $cscheme_table WHERE group_id=?)) AND new_version IS NULL"
,
$group_id
);
if ( $isolate_count > 1 ) {
my $url = "$self->{'system'}->{'script_name'}?db=$self->{'instance'}&amp;page=query&amp;"
. "designation_field1=cg_$cscheme->{'id'}_group&amp;designation_value1=$group_id&amp;submit=1";
$cg_buffer .=
qq(<dt>group</dt><dd><a href="$url">$group_id</a> ($isolate_count isolates)</dd>\n);
$cg_buffer .= qq(group: <a href="$url">$group_id ($isolate_count isolates)</a><br />\n);
}
}
}
}
if ($cg_buffer) {
$cg_buffer = qq(<div style="float:left"><h3>Scheme: $cscheme->{'name'}</h3>\n)
. qq(<dl class="data">$cg_buffer</dl></div>\n);
my $plural = $cscheme->{'inclusion_threshold'} == 1 ? q() : q(es);
$cg_buffer =
qq(<div style="float:left;margin-right:2em"><h3>Scheme: $cscheme->{'name'}</h3>\n)
. qq(<p>$scheme_info->{'description'}<br />$cscheme->{'inclusion_threshold'} mismatch$plural.)
. q(<br />Single-linkage cluster.<br />)
. qq($cg_buffer</div>\n);
$buffer .= $cg_buffer;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment