<commit_before>package EnsEMBL::Admin::Component::Healthcheck::Details;

use strict;

use base qw(EnsEMBL::Admin::Component::Healthcheck);

sub caption {
  my $object = shift->object;
  my $extra  = $object->view_type && $object->view_param ? sprintf(' (%s)', $object->view_param) : '';
  return "Healthcheck details$extra";
}

sub content {
  ## @return HTML to be displayed
  my $self = shift;

  my $object  = $self->object;
  my $reports = $object->rose_objects('reports');
  my $param   = $object->view_param;
  my $type    = $object->view_type;

  return $self->no_healthcheck_found unless $reports && @$reports;

  # if no filter selected, display the failure summary table for the given view type
  if (!$param) {
    return sprintf('<p class="hc_p">Click on a %s to view details</p>%s', $object->view_title, $self->failure_summary_table({
      'count'         => $self->group_report_counts($reports, [$type])->{$type},
      'type'          => $type,
      'session_id'    => $object->last_session_id,
      'release'       => $object->requested_release,
      'default_list'  => $object->get_default_list
    }));
  }

  my $html    = '';
  my $db_list = [];

  #group all reports by database_name
  my $grouped_reports = {};
  push @{$grouped_reports->{$_->database_name} ||= []}, $_ for @$reports;

  my $serial_number = 0;
  
  $html .= sprintf('<form action="" method="get"><p class="hc-p-right">View in release: %s&nbsp;<input type="submit" value="Go" /><input type="hidden" name="q" value="%s" /></p></form>',
    $self->render_all_releases_selectbox,
    $param
  ) if $type ne 'database_name';
  $html .= qq{<div class="hc-infobox">
            <p>For each database, reports are sorted on the basis of Date (initial failure date) with latest report appearing on the top.</p>
            <p>Reports in <span class="hc-problem">this colour</span> have not been annotated 'manual ok'.</p>
            <p>Reports appearing <span class="hc-problem hc-new">bold</span> (or <span class="hc-new">bold</span>) are for the recently appeared problems.</p>
  </div>};

  my $js_ref = 0; #counter used by JavaScript only
  foreach my $database_name (sort keys %$grouped_reports) {
  
    $js_ref++;
    my $table = $self->new_table;
    
    $table->add_columns(#note - use the space properly, we have too much to display in annotation and text columns
      {'key' => 'db_sp_tc', 'title' => $self->_get_first_column($object->function),       'width' => qq(20%)},
      {'key' => 'text',     'title' => 'Text',                                            'width' => qq(40%)},
      {'key' => 'comment',  'title' => 'Annotation',                                      'width' => qq(40%)},
      {'key' => 'team',     'title' => 'Team/person responsible',                         'width' => '100px'},
      {'key' => 'created',  'title' => '<abbr title="Initial Failure Date">Date</abbr>',  'width' => '60px' },
    );
    
    #sort reports on the basis of creation time 
    my $i = 0;
    my $db_reports = [];
    my $temp = { map { ($_->created || '0').++$i => $_ } @{$grouped_reports->{$database_name}} };
    push @$db_reports, $temp->{$_} for reverse sort keys %$temp;

    foreach my $report (@$db_reports) {
      my $report_id  = $report->report_id;
      my $db_sp_tc   = [];
      for (qw(database_type species testcase)) {
        next if $_ eq $type;
        push @$db_sp_tc, $self->get_healthcheck_link({'type' => $_, 'param' => ucfirst($report->$_), 'release' => $object->requested_release, 'cut_long' => 'cut'});
      }

      #annotation column
      my $annotation    = '';
      if ($report->annotation) {
        $annotation    .= $report->annotation->comment if $report->annotation->comment;<commit_msg>title does not filter html value, so better just provide text value<commit_after>package EnsEMBL::Admin::Component::Healthcheck::Details;

use strict;

use base qw(EnsEMBL::Admin::Component::Healthcheck);

sub caption {
  my $object = shift->object;
  my $extra  = $object->view_type && $object->view_param ? sprintf(' (%s)', $object->view_param) : '';
  return "Healthcheck details$extra";
}

sub content {
  ## @return HTML to be displayed
  my $self = shift;

  my $object  = $self->object;
  my $reports = $object->rose_objects('reports');
  my $param   = $object->view_param;
  my $type    = $object->view_type;

  return $self->no_healthcheck_found unless $reports && @$reports;

  # if no filter selected, display the failure summary table for the given view type
  if (!$param) {
    return sprintf('<p class="hc_p">Click on a %s to view details</p>%s', $object->view_title, $self->failure_summary_table({
      'count'         => $self->group_report_counts($reports, [$type])->{$type},
      'type'          => $type,
      'session_id'    => $object->last_session_id,
      'release'       => $object->requested_release,
      'default_list'  => $object->get_default_list
    }));
  }

  my $html    = '';
  my $db_list = [];

  #group all reports by database_name
  my $grouped_reports = {};
  push @{$grouped_reports->{$_->database_name} ||= []}, $_ for @$reports;

  my $serial_number = 0;
  
  $html .= sprintf('<form action="" method="get"><p class="hc-p-right">View in release: %s&nbsp;<input type="submit" value="Go" /><input type="hidden" name="q" value="%s" /></p></form>',
    $self->render_all_releases_selectbox,
    $param
  ) if $type ne 'database_name';
  $html .= qq{<div class="hc-infobox">
            <p>For each database, reports are sorted on the basis of Date (initial failure date) with latest report appearing on the top.</p>
            <p>Reports in <span class="hc-problem">this colour</span> have not been annotated 'manual ok'.</p>
            <p>Reports appearing <span class="hc-problem hc-new">bold</span> (or <span class="hc-new">bold</span>) are for the recently appeared problems.</p>
  </div>};

  my $js_ref = 0; #counter used by JavaScript only
  foreach my $database_name (sort keys %$grouped_reports) {
  
    $js_ref++;
    my $table = $self->new_table;
    
    $table->add_columns(#note - use the space properly, we have too much to display in annotation and text columns
      {'key' => 'db_sp_tc', 'title' => $self->_get_first_column($object->function), 'width' => qq(20%)},
      {'key' => 'text',     'title' => 'Text',                                      'width' => qq(40%)},
      {'key' => 'comment',  'title' => 'Annotation',                                'width' => qq(40%)},
      {'key' => 'team',     'title' => 'Team/person responsible',                   'width' => '100px'},
      {'key' => 'created',  'title' => 'Initial Failure Date',                      'width' => '60px' },
    );
    
    #sort reports on the basis of creation time 
    my $i = 0;
    my $db_reports = [];
    my $temp = { map { ($_->created || '0').++$i => $_ } @{$grouped_reports->{$database_name}} };
    push @$db_reports, $temp->{$_} for reverse sort keys %$temp;

    foreach my $report (@$db_reports) {
      my $report_id  = $report->report_id;
      my $db_sp_tc   = [];
      for (qw(database_type species testcase)) {
        next if $_ eq $type;
        push @$db_sp_tc, $self->get_healthcheck_link({'type' => $_, 'param' => ucfirst($report->$_), 'release' => $object->requested_release, 'cut_long' => 'cut'});
      }

      #annotation column
      my $annotation    = '';
      if ($report->annotation) {
        $annotation    .= $report->annotation->comment if $report->annotation->comment;
{'fraction_non_alphanumeric': 0.17767379679144385, 'fraction_numerical': 0.004010695187165776, 'mean_word_length': 3.048160173160173, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 169, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4042113', 'n_tokens_mistral': 2463, 'n_tokens_neox': 2370, 'n_words': 623}