Dzahn has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/366996 )

Change subject: fix rank.php calculations
......................................................................


fix rank.php calculations

Fix various problems with the rank calculations
after switch to PDO.

Bug: T168474
Change-Id: I738ca1122ab7e031a7ce54c6b5f2b5acb6f1b389
---
M var/www/wikistats/rank.php
1 file changed, 9 insertions(+), 13 deletions(-)

Approvals:
  jenkins-bot: Verified
  Dzahn: Verified; Looks good to me, approved



diff --git a/var/www/wikistats/rank.php b/var/www/wikistats/rank.php
index ac9bf9f..fd4ba37 100644
--- a/var/www/wikistats/rank.php
+++ b/var/www/wikistats/rank.php
@@ -44,7 +44,7 @@
     die();
 }
 
-$count=1;
+$count=0;
 $arcount=0;
 $lang_check="FALSE";
 $languages=array();
@@ -154,19 +154,18 @@
 $query = "select id,prefix from ${table} where prefix is not null order by 
good desc,total desc";
 $fnord = $wdb->prepare($query);
 $fnord -> execute();
-$num_rows = $wdb->query($query)->fetchColumn();
 
 while ($row = $fnord->fetch()) {
 
+    $count++;
     if ($row[prefix]==$lang) {
         $rank_project=$count;
-        $number_project=$num_rows;
     }
-
-    $count++;
 }
 
-$count=1;
+$number_project=$count;
+
+$count=0;
 
 $query = <<<FNORD
 (select 
prefix,good,lang,loclang,total,edits,admins,users,images,ts,'wikipedias' as 
type from wikipedias where prefix is not null)
@@ -184,21 +183,18 @@
 $fnord = $wdb->prepare($query);
 $fnord -> execute();
 
-$num_rows = $wdb->query($query)->fetchColumn();
-
 while ($row = $fnord->fetch()) {
-
+    $count++;
     if ($row[prefix]==$lang AND $row[type]==$table) {
         $rank_global=$count;
-        $number_global=$num_rows;
         $type=$row[type];
     }
-
-    $count++;
 }
 
-echo "$lang.$family $rank_project $number_project $rank_global 
$number_global\n";
+$number_global=$count;
 
+echo "$lang.$family $rank_project $number_project $rank_global 
$number_global\n\n";
+#echo "debug: lang.family $lang.$family rank_project: $rank_project 
number_project: $number_project rank_global: $rank_global number_global: 
$number_global\n";
 if ($rank_project==""){
     echo "\n! this language version does not seem to exist yet in this 
project";
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/366996
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I738ca1122ab7e031a7ce54c6b5f2b5acb6f1b389
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/wikistats
Gerrit-Branch: master
Gerrit-Owner: Dzahn <dz...@wikimedia.org>
Gerrit-Reviewer: Dzahn <dz...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to