Lokal Profil has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391139 )

Change subject: [WIP] Fix bad idx entries
......................................................................

[WIP] Fix bad idx entries

The idx table is an ugly hack which concatenates four values only to
later explode it. But if the strings are too long for the field
parts are left out and as a result explodingthe value returns
the wrong number of fields.

WIP because:
* Something else is editing these values meaning the last two values
are lost before they reach makeIdx.

Bug: T174503
Change-Id: I42f6b0d97f52e99ac79a3960c21e91c1721b600c
---
M README.md
M api/includes/Statistics.php
2 files changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/labs/tools/heritage 
refs/changes/39/391139/1

diff --git a/README.md b/README.md
index 4a30350..a39f105 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,9 @@
 
 # Update the monuments_all table
 docker-compose run --rm db mysql -h db s51138__heritage_p --user=heritage 
--password=password < erfgoedbot/sql/fill_table_monuments_all.sql
+
+# Update the statistics table
+docker-compose run --rm web php ../maintenance/_buildStats.php
 ```
 
 The web interface will be accessible on http://localhost:8000/
diff --git a/api/includes/Statistics.php b/api/includes/Statistics.php
index 859e5c0..e08f996 100644
--- a/api/includes/Statistics.php
+++ b/api/includes/Statistics.php
@@ -15,6 +15,9 @@
        var $axis = [];
        static $fieldPrefix = 'st_';
 
+       // must be at least 25 less than max length for idx field
+       static $maxMuniLength = 70;
+
        var $lastDay = '';
        static $aItems = [
                'address', 'address_pct', 'coordinates', 'coordinates_pct', 
'image',
@@ -100,6 +103,9 @@
        static function makeIdx( $row ) {
                // Need to replace any naturally occuring ':' in row[1]
                $muni = str_replace( ':', '&#58;', $row[1] );
+               if ( strlen( $muni ) >= Statistics::$maxMuniLength ) {
+                       $muni = substr( $muni, 0, Statistics::$maxMuniLength - 
1 ) . '…';
+               }
                return $row[0] . ':' . $muni . ':' . $row[2] . ':' . $row[3];
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I42f6b0d97f52e99ac79a3960c21e91c1721b600c
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/heritage
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <lokal.pro...@gmail.com>

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

Reply via email to