[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [NEW] Tiki-stats: Display trackers stats

"Domeshow Emmanuel \(@Domeshow\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68c455ee47b79_2cde724733d7@gitlab-sidekiq-low-urgency-cpu-bound-v2-8657787f69-7kdsq.mail>

Domeshow Emmanuel pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki


Commits:
77a22584 by Domeshow Emmanuel at 2025-09-12T20:11:53+03:00
[NEW] Tiki-stats: Display trackers stats
---
* [FIX] Tiki Stats - Stats for Trackers are wrong
---
* [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

(cherry picked from commit d6d5fce6d10feefe8835817e91f5eaaccdc7785f)

245c1ca1 [FIX] Tiki Stats - Stats for Trackers are wrong

Co-authored-by: Domeshow Emmanuel <[email protected]>

See merge request tikiwiki/tiki!8569

(cherry picked from commit fa032f2e3e0188aaa50465292ad5d7f49e2625ea)

* [NEW] Tiki-stats: Display trackers stats
---
* [ENH] tiki-stats.php: enhance mysql queries to be more readable

* [NEW, ENH] tiki-stats.php: retrieve trackers stats, size and nbre of records and display them

* [NEW] tiki-stats.php: get and display trackers stats

* [NEW] tiki-stats.php: tracker stats initialization

See merge request tikiwiki/tiki!4910

(cherry picked from commit b6a87023b6510b08e24a056663fda99ccfb7ad20)

See merge request tikiwiki/tiki!8570

- - - - -


3 changed files:

- lib/stats/statslib.php
- templates/tiki-stats.tpl
- tiki-stats.php


Changes:

=====================================
lib/stats/statslib.php
=====================================
@@ -585,4 +585,35 @@ class StatsLib extends TikiLib
         $ret['ydata'] = $ydata;
         return $ret;
     }
+
+    /**
+     * @return array
+     */
+    public function trackerStats()
+    {
+        $stats = [];
+        $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
=====================================
@@ -40,6 +40,9 @@
             {if $best_objects_stats}
                 {button href="#best_objects_stats_lastweek" _type="link" class="btn btn-link" _icon_name="sort-numeric-asc" _text="{tr}Most viewed objects in the last 7 days{/tr}"}
             {/if}
+            {if $tracker_stats}
+                {button href="#tracker_stats" _type="link" class="btn btn-link" _icon_name="sort-numeric-asc" _text="{tr}Trackers{/tr}"}
+            {/if}
         </div>
 
         <h2 id="site_stats">{tr}Site Stats{/tr}</h2>
@@ -358,6 +361,33 @@
             </div>
         {/if}
 
+        {if $tracker_stats}
+            <h2 id="tracker_stats">{tr}Tracker Stats{/tr}</h2>
+            {cycle values="odd,even" print=false advance=false}
+            <div class="table-responsive">
+                <table class="table table-striped">
+                    {foreach $tracker_stats as $key => $data}
+                        <tr>
+                            <td>
+                            {if $key == "trackers"}{tr}Trackers{/tr}
+                            {elseif $key == "tracker_fields"}{tr}Tracker Fields{/tr}
+                            {elseif $key == "tiki_tracker_items"}{tr}Tiki Tracker Items{/tr}
+                            {elseif $key == "tiki_tracker_item_attachments"}{tr}Tiki Tracker Item Attachments{/tr}
+                            {elseif $key == "tiki_tracker_options"}{tr}Tiki Tracker Options{/tr}
+                            {/if}
+                            </td>
+                            <td>
+                            {$data.dataLengthMb} Mb
+                            </td>
+                            <td style="text-align:right;">
+                            {$data.rowCount}
+                            </td>
+                        </tr>
+                    {/foreach}
+                </table>
+            </div>
+        {/if}
+
         {if $best_objects_stats_between}
             <h2 id="best_objects_stats_between">{tr}Most viewed objects in period{/tr}</h2>
             <form method="post" action="tiki-stats.php">


=====================================
tiki-stats.php
=====================================
@@ -74,6 +74,13 @@ if ($prefs['feature_quizzes'] == 'y') {
     $quiz_stats = false;
 }
 $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();
+} else {
+    $tracker_stats = false;
+}
+$smarty->assign_by_ref('tracker_stats', $tracker_stats);
 $user_stats = $statslib->user_stats();
 $smarty->assign_by_ref('user_stats', $user_stats);
 $site_stats = $statslib->site_stats();



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/77a22584d8d8ddf8e69e9f7f567655e9724cfb2e

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/77a22584d8d8ddf8e69e9f7f567655e9724cfb2e
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.