[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Performance stats: Fix pagination count ignoring search filter & validate $order parameter

"ushindi bienvenu \(@usbbush\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a2bf1e925f84_383cf6b883352@gitlab-sidekiq-low-urgency-cpu-bound-v2-7cf778b8c7-djlgj.mail>

ushindi bienvenu pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
dc62864a by UshindiG at 2026-06-12T11:29:47+00:00
[FIX] Performance stats: Fix pagination count ignoring search filter & validate $order parameter
---
* [FIX] performance stats: Fix pagination count ignoring search filter

See merge request tikiwiki/tiki!9807

- - - - -


2 changed files:

- lib/performance/performancestatslib.php
- tiki-performance_stats.php


Changes:

=====================================
lib/performance/performancestatslib.php
=====================================
@@ -48,6 +48,7 @@ class PerformanceStatsLib extends TikiLib
      */
     public function getRequestsBasedOnAverageRequestTime(int $amount = 25, int $offset = 0, string $find = '', string $order = 'DESC', string $orderType = '')
     {
+        $order = strtoupper($order) === 'ASC' ? 'ASC' : 'DESC';
         if ($orderType == 'no_of_requests') {
             return $this->query("SELECT url, round(AVG(time_taken)) AS average_time_taken, COUNT(url) AS number_of_requests FROM tiki_performance WHERE url LIKE ? GROUP BY url ORDER BY number_of_requests $order LIMIT $amount OFFSET $offset", ["%$find%"]);
         } else {
@@ -65,6 +66,7 @@ class PerformanceStatsLib extends TikiLib
      */
     public function getRequestsBasedOnMaximumProcessingTime(int $amount = 25, int $offset = 0, string $find = '', string $order = 'DESC')
     {
+        $order = strtoupper($order) === 'ASC' ? 'ASC' : 'DESC';
         return $this->query("SELECT url, MAX(time_taken) AS maximum_time_taken FROM tiki_performance WHERE url LIKE ? GROUP BY url ORDER BY maximum_time_taken $order LIMIT $amount OFFSET $offset", ["%$find%"]);
     }
 
@@ -75,6 +77,9 @@ class PerformanceStatsLib extends TikiLib
      */
     public function getRequestsGroupedByAmount(string $find = '')
     {
+        if ($find !== '') {
+            return $this->getOne('SELECT COUNT(DISTINCT(url)) FROM tiki_performance WHERE url LIKE ?', ["%$find%"]);
+        }
         return $this->getOne('SELECT COUNT(DISTINCT(url)) FROM tiki_performance');
     }
 


=====================================
tiki-performance_stats.php
=====================================
@@ -72,7 +72,7 @@ $maximumStatOrder = validateDirection($_REQUEST['maximum_stat_order'] ?? null);
 
 $smarty->assign('performance_stats_lib', $performanceLib);
 $smarty->assign('find', $find);
-$smarty->assign('pages_count', $performanceLib->getRequestsGroupedByAmount());
+$smarty->assign('pages_count', $performanceLib->getRequestsGroupedByAmount($find));
 $smarty->assign_by_ref('average_stat_offset', $averageStatOffset);
 $smarty->assign_by_ref('average_stat_order', $averageStatOrder);
 $smarty->assign_by_ref('maximum_stat_offset', $maximumStatOffset);



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/dc62864a3d7923e0676fc54fe49b1fbe1769b793
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
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.