You are here

function apachesolr_stats_facet_usage_table in Apache Solr Statistics 6

Same name and namespace in other branches
  1. 6.3 apachesolr_stats.module \apachesolr_stats_facet_usage_table()
  2. 7 apachesolr_stats.module \apachesolr_stats_facet_usage_table()

Returns a themed table for facet usage

Parameters

array $facets: An array of calculated data to report.

Return value

string HTML for a themed table containing the report data.

1 call to apachesolr_stats_facet_usage_table()
apachesolr_stats_generate_report_elements in ./apachesolr_stats.module
Generates report elements for the given granularity.

File

./apachesolr_stats.module, line 594
Keeps and reports statistics about Apache Solr usage and performance.

Code

function apachesolr_stats_facet_usage_table($facets) {

  // Report usage in table
  $header = array(
    array(
      'data' => t('Facet ID'),
      'Xfield' => 'id',
      'sort' => 'asc',
    ),
    array(
      'data' => t('Facet info'),
      'Xfield' => 'info',
      'sort' => '',
    ),
    array(
      'data' => t('Queries containing this facet'),
      'Xfield' => 'queries',
      'sort' => '',
    ),
    array(
      'data' => t('% of queries containing this facet'),
      'Xfield' => 'queries',
      'sort' => '',
    ),
  );
  foreach ($facets as $fieldname => $facet) {
    $rows[$fieldname][] = $fieldname;
    $rows[$fieldname][] = $facet['info'];
    $rows[$fieldname][] = $facet['usage'];
    $rows[$fieldname][] = sprintf("%2.1f%%", $facet['usage'] / $facets['any']['usage'] * 100);

    #$rows[$fieldname][] = $facet['clickthru'];

    #if ($facet['usage']>0) {

    #  $rows[$fieldname][] = sprintf("%2.1f%%", ($facet['clickthru'] / $facet['usage'])*100);

    #}
  }
  $output = theme('table', $header, $rows, array(
    'style' => 'font-size:80%',
  ));
  return $output;
}