Skip to content

Commit

Permalink
Merge pull request #3115 from 10up/chore/remove-stats-averages
Browse files Browse the repository at this point in the history
Remove time averages
  • Loading branch information
felipeelia authored Nov 7, 2022
2 parents 693db77 + 0753b2e commit a2ecbdc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 76 deletions.
43 changes: 0 additions & 43 deletions assets/js/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,46 +100,3 @@ if (queriesTotalChart) {
},
});
}

const queriesTimeChart = document.getElementById('queriesTimeChart');
if (queriesTimeChart) {
new Chart(queriesTimeChart, {
type: 'pie',
data: {
labels: ['Avg indexing time in ms', 'Avg query time in ms'],
datasets: [
{
label: '',
backgroundColor: ['#9ea6c7', '#93b3d5'],
data: [epChartData.index_time_in_millis, epChartData.query_time_in_millis],
},
],
},
options: {
responsive: false,
title: {
display: true,
},
legend: {
position: 'right',
},
tooltips: {
callbacks: {
/**
* Appends the string milliseconds after tooltip value
*
* @param {object} item Tooltip item
* @param {object} data Tooltip data
* @returns {string} current value in milliseconds
*/
label(item, data) {
const dataset = data.datasets[item.datasetIndex];
const currentValue = dataset.data[item.index];

return `${+currentValue} milliseconds`;
},
},
},
},
});
}
29 changes: 4 additions & 25 deletions includes/classes/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ class Stats {
* @since 3.2
*/
protected $localized = [
'index_total' => 0,
'index_time_in_millis' => 0,
'query_total' => 0,
'query_time_in_millis' => 0,
'suggest_time_in_millis' => 0,
'suggest_total' => 0,
'indices_data' => [],
'index_total' => 0,
'query_total' => 0,
'suggest_total' => 0,
'indices_data' => [],
];

/**
Expand Down Expand Up @@ -117,7 +114,6 @@ public function build_stats( $force = false ) {
}

$this->populate_indices_stats();
$this->populate_indices_averages();

if ( Utils\is_epio() ) {
$node_stats = $this->remote_request_helper( '_nodes/stats/discovery?format=json' );
Expand Down Expand Up @@ -200,23 +196,6 @@ public function get_indices_for_site( $site_id ) {
return $indices;
}

/**
* Populate cluster performance data. These use the total key so averages include both primary and replica shards
*
* @since 3.x
*/
private function populate_indices_averages() {

if ( empty( $this->stats['_all']['total'] ) ) {
return;
}

// General cluster performance stats
$this->localized['index_time_in_millis'] = $this->stats['_all']['total']['indexing']['index_time_in_millis'];
$this->localized['query_time_in_millis'] = $this->stats['_all']['total']['search']['query_time_in_millis'];
$this->localized['suggest_time_in_millis'] = $this->stats['_all']['total']['search']['suggest_time_in_millis'];
}

/**
* Populate index storage capacity and metrics
* Note: in the numbers below, those using the total key are counting values across all primary and replica shards
Expand Down
8 changes: 0 additions & 8 deletions includes/partials/stats-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,6 @@
</div>
</div>
</div>
<div class="stats-queries postbox">
<h2 class="hndle"><?php esc_html_e( 'Queries & Indexing Time', 'elasticpress' ); ?></h2>
<div class="ep-qchart-container">
<div class="inside">
<canvas id="queriesTimeChart" width="400" height="400"></canvas>
</div>
</div>
</div>
</div>
<?php else : ?>
<p>
Expand Down

0 comments on commit a2ecbdc

Please sign in to comment.