[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] Tiki Stats - Stats for Trackers are wrong
"Domeshow Emmanuel \(@Domeshow\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <68c3f7b9c5255_2cde6fc389b1@gitlab-sidekiq-low-urgency-cpu-bound-v2-865b9c788c-lkgnn.mail> |
Domeshow Emmanuel pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki Commits: d6d5fce6 by Domeshow Emmanuel at 2025-09-12T13:30:08+03:00 [FIX] Tiki Stats - Stats for Trackers are wrong --- * [FIX] Tiki Stats - Stats for Trackers are wrong --- * [FIX] Tiki Stats - Stats for Trackers are wrong See merge request tikiwiki/tiki!8420 (cherry picked from commit 7af5f0bbd38934696b8c2e1c93ebf0b7169577f1) 2f20cea7 [FIX] Tiki Stats - Stats for Trackers are wrong Co-authored-by: Domeshow Emmanuel <[email protected]> See merge request tikiwiki/tiki!8566 - - - - - 3 changed files: - lib/stats/statslib.php - templates/tiki-stats.tpl - tiki-stats.php Changes: ===================================== lib/stats/statslib.php ===================================== @@ -592,11 +592,28 @@ class StatsLib extends TikiLib public function trackerStats() { $stats = []; - $stats["trackers"] = $this->query("show table status WHERE `Name` = 'tiki_trackers'", []); - $stats["tracker_fields"] = $this->query("show table status WHERE `Name` = 'tiki_tracker_fields'", []); - $stats["tiki_tracker_items"] = $this->query("show table status WHERE `Name` = 'tiki_tracker_items'", []); - $stats["tiki_tracker_item_attachments"] = $this->query("show table status WHERE `Name` = 'tiki_tracker_item_attachments'", []); - $stats["tiki_tracker_options"] = $this->query("show table status WHERE `Name` = 'tiki_tracker_options'", []); + $tables = [ + 'trackers' => 'tiki_trackers', + 'tracker_fields' => 'tiki_tracker_fields', + 'tiki_tracker_items' => 'tiki_tracker_items', + 'tiki_tracker_item_attachments' => 'tiki_tracker_item_attachments', + 'tiki_tracker_options' => 'tiki_tracker_options', + ]; + + foreach ($tables as $key => $table) { + // Accurate row count + $stats[$key]['rowCount'] = (int) $this->getOne("SELECT COUNT(*) FROM `$table`", []); + + // Table size via SHOW TABLE STATUS + $stat = $this->query("SHOW TABLE STATUS WHERE `Name` = ?", [$table]); + $dataLength = 0; + + if (isset($stat->result[0])) { + $dataLength = (int) $stat->result[0]['Data_length']; + } + + $stats[$key]['dataLengthMb'] = $dataLength / 1024 / 1024; + } return $stats; } } ===================================== templates/tiki-stats.tpl ===================================== @@ -396,7 +396,7 @@ <td> {$data.dataLengthMb} Mb </td> - <td> + <td style="text-align:right;"> {$data.rowCount} </td> </tr> ===================================== tiki-stats.php ===================================== @@ -99,18 +99,6 @@ $smarty->assign_by_ref('quiz_stats', $quiz_stats); if ($prefs['feature_trackers'] == 'y') { // Retrieve trackers statistics and prepare extracted data for display. $tracker_stats = $statslib->trackerStats(); - $tracker_stat_data = []; - foreach ($tracker_stats as $key => $stat) { - if (isset($stat->result[0])) { - $tracker_stat_data = $stat->result[0]; - $extractedTrackerStatsData[$key] = [ - 'dataLengthMb' => $tracker_stat_data['Data_length'] / 1024 / 1024, // Get data lenght in Mb. - 'rowCount' => $tracker_stat_data['Rows'] + 1 // Number of records + 1, because it starts with 0 index when counting. - ]; - } - } - - $tracker_stats = $extractedTrackerStatsData; } else { $tracker_stats = false; } View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/d6d5fce6d10feefe8835817e91f5eaaccdc7785f -- View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/d6d5fce6d10feefe8835817e91f5eaaccdc7785f You're receiving this email because of your account on gitlab.com. _______________________________________________ TikiWiki-cvs mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs