<commit_before>package EnsEMBL::Web::Component::Healthcheck::Databases;

use strict;
use warnings;
no warnings "uninitialized";

use DBI;

use base qw(EnsEMBL::Web::Component);

sub _init {
  my $self = shift;
  $self->cacheable( 1 );
  $self->ajaxable(  0 );
  $self->configurable( 0 );
}

sub content {
  my $self = shift;
  my $html;

  my @servers = ('ens-staging1', 'ens-staging2');
  my %configured_dbs;

  my $SD = $self->object->species_defs;
  my @db_types = qw(DATABASE_CORE DATABASE_OTHERFEATURES DATABASE_VARIATION DATABASE_FUNCGEN);

  foreach my $hostname (@servers) {
    $html .= "<h2>$hostname</h2><ul>";
    my $drh = DBI->install_driver('mysql');
    my @dbs = $drh->func($hostname, '3306', 'ensro', '_ListDBs');
    my $matchstring = '_core|_otherfeatures|_cdna|_variation|_funcgen|_compara';
    my $fullmatch = '('.$matchstring.')_'.$SD->ENSEMBL_VERSION.'_([a-z0-9]{2,5})';
    my $previous = ''; 
    my $indent = 1;
    foreach my $dbname (@dbs) {
      if ($dbname =~ /$matchstring/ && $dbname !~ /master/) {
        $dbname =~ /^([a-z]+_[a-z]+)/;
        my $spname = $1;
        ## Close any previous species' sublist
        if ($previous && $spname ne $previous && !$indent) {
          $html .= "</ul>";
          $indent = 1;
        }
        ## Start a new sublist if wanted
        if ($previous && $spname eq $previous && $indent) {
          $html .= '<ul>';
          $indent = 0;
        }
        #warn ">>> SPECIES $spname"; 
        if ($indent) {
          $html .= "<li><strong>$dbname</strong></li>";
        }
        else {
          $html .= "<li>$dbname</li>";
        }
        $previous = $spname;
      }
    }
    if (!$indent) {
      $html .= '</ul>';
    }
    $html .= '</ul>';
  }
  return $html;
}

1;
<commit_msg>Added checking against healthcheck db list - needs testing when healthchecks start for next release!<commit_after>package EnsEMBL::Web::Component::Healthcheck::Databases;

use strict;
use warnings;
no warnings "uninitialized";

use DBI;

use base qw(EnsEMBL::Web::Component);

sub _init {
  my $self = shift;
  $self->cacheable( 1 );
  $self->ajaxable(  0 );
  $self->configurable( 0 );
}

sub content {
  my $self = shift;
  my $html;
  $html .= '<h1>Database list</h1>';
  $html .= "<p><strong>Y/N</strong>: is this database being healthchecked?</p>";

  my @servers = ('ens-staging1', 'ens-staging2');
  my @databases = $self->object->database_names;
  my %db_check = map { $_ => 1 } @databases;
  my %configured_dbs;

  my $SD = $self->object->species_defs;
  my @db_types = qw(DATABASE_CORE DATABASE_OTHERFEATURES DATABASE_VARIATION DATABASE_FUNCGEN);

  foreach my $hostname (@servers) {
    $html .= "<h2>$hostname</h2>";
    $html .= "<ul>";
    my $drh = DBI->install_driver('mysql');
    my @dbs = $drh->func($hostname, '3306', 'ensro', '_ListDBs');
    my $matchstring = '_core|_otherfeatures|_cdna|_variation|_funcgen|_compara';
    my $fullmatch = '('.$matchstring.')_'.$SD->ENSEMBL_VERSION.'_([a-z0-9]{2,5})';
    my $previous = ''; 
    my $indent = 1;
    foreach my $dbname (@dbs) {
      if ($dbname =~ /$matchstring/ && $dbname !~ /master/) {
        $dbname =~ /^([a-z]+_[a-z]+)/;
        my $spname = $1;
        ## Close any previous species' sublist
        if ($previous && $spname ne $previous && !$indent) {
          $html .= "</ul>";
          $indent = 1;
        }
        ## Start a new sublist if wanted
        if ($previous && $spname eq $previous && $indent) {
          $html .= '<ul>';
          $indent = 0;
        }
        if ($indent) {
          $html .= "<li><strong>$dbname</strong>";
        }
        else {
          $html .= "<li>$dbname";
        }
        $html .= $db_check{$dbname} ? ' <span style="color:red;font-weight:bold">(Y)</span>' 
                                    : ' <span style="color:green;font-weight:bold">(N)</span>';
        $html .= '</li>';
        $previous = $spname;
      }
    }
    if (!$indent) {
      $html .= '</ul>';
    }
    $html .= '</ul>';
  }
  return $html;
}

1;

{'fraction_non_alphanumeric': 0.1951340615690169, 'fraction_numerical': 0.01067527308838133, 'mean_word_length': 2.518777292576419, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6077496', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1429, 'n_words': 316}