svn: /web/doc-editor/trunk/ install/firstRun.php js/locale/fr.js js/ui/component/StaleFileGrid.js js/ui/component/SummaryGrid.js js/ui/component/TranslationGraph.js js/ui/component/TranslatorGrid.js php/ExtJsController.php php/RepositoryFetcher.php php/RepositoryManager.php php/TranslationStatistic.php php/TranslatorStatistic.php scripts/cron/update_data.php themes/style.css

[email protected] (Yannick Torres)
Newsgroups php.doc.web
Message-ID <[email protected]>
yannick                                  Mon, 14 Dec 2009 21:28:16 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=292141

Log:
Modify the way we compute summary information for documentation & translators. This change speed up the display of the main UI

Changed paths:
    U   web/doc-editor/trunk/install/firstRun.php
    U   web/doc-editor/trunk/js/locale/fr.js
    U   web/doc-editor/trunk/js/ui/component/StaleFileGrid.js
    U   web/doc-editor/trunk/js/ui/component/SummaryGrid.js
    U   web/doc-editor/trunk/js/ui/component/TranslationGraph.js
    U   web/doc-editor/trunk/js/ui/component/TranslatorGrid.js
    U   web/doc-editor/trunk/php/ExtJsController.php
    U   web/doc-editor/trunk/php/RepositoryFetcher.php
    U   web/doc-editor/trunk/php/RepositoryManager.php
    U   web/doc-editor/trunk/php/TranslationStatistic.php
    U   web/doc-editor/trunk/php/TranslatorStatistic.php
    U   web/doc-editor/trunk/scripts/cron/update_data.php
    U   web/doc-editor/trunk/themes/style.css
svn-diffs-292141.txt (text/x-diff, 44.7 KB)
Modified: web/doc-editor/trunk/install/firstRun.php
===================================================================
--- web/doc-editor/trunk/install/firstRun.php	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/install/firstRun.php	2009-12-14 21:28:16 UTC (rev 292141)
@@ -2,8 +2,10 @@
 error_reporting(E_ALL);
 set_time_limit(0);

+require_once '../php/html.templates.php';
 require_once '../php/RepositoryManager.php';
-require_once '../php/html.templates.php';
+require_once '../php/TranslationStatistic.php';
+require_once '../php/TranslatorStatistic.php';

 $isCLI = (PHP_SAPI == 'cli');

@@ -46,6 +48,10 @@
 // Parse translators
 $rm->updateTranslatorInfo();

+// Compute all summary
+TranslationStatistic::getInstance()->computeSummary('all');
+TranslatorStatistic::getInstance()->computeSummary('all');
+
 // We update the last update date/time into DB
 $rm->setLastUpdate();


Modified: web/doc-editor/trunk/js/locale/fr.js
===================================================================
--- web/doc-editor/trunk/js/locale/fr.js	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/js/locale/fr.js	2009-12-14 21:28:16 UTC (rev 292141)
@@ -132,9 +132,7 @@
 i18n["There is currently an update in progress.<br/>You can\'t perform an update now."] = "Il y a actuellement une mise à jour en cours.<br/>Vous ne pouvez pas l\'effectuer maintenant";
 i18n["in {0}"] = "dans le dossier {0}";
 i18n["Up to date files"] = "Fichiers à jour";
-i18n["Old files"] = "Anciens fichiers";
-i18n["Critical files"] = "Fichiers critiques";
-i18n["Files without revision tag"] = "Fichiers sans balise revcheck";
+i18n["Stale files"] = "Fichiers à mettre à jour";
 i18n["Files available for translation"] = "Fichiers à traduire";
 i18n["Total"] = "Total";
 i18n["Posted by"] = "Proposé par";
@@ -231,14 +229,14 @@
         i18n["Percent of files"] = "% de fichiers";
         i18n["Size of files (kB)"] = "Taille des fichiers (kB)";
         i18n["Percent of size"] = "% de la taille";
-    i18n["Translators"] = "Traducteurs";
+        i18n["{0} Translators"] = "{0} Traducteurs";
+        i18n["Translators"] = "Traducteurs";
         i18n["Name"] = "Nom";
         i18n["Email"] = "Email";
         i18n["Nick"] = "Nick";
         i18n["VCS"] = "VCS";
         i18n["UptoDate"] = "À jour";
-        i18n["Old"] = "Ancien";
-        i18n["Critical"] = "Critique";
+        i18n["Stale"] = "À mettre à jour";
         i18n["Sum"] = "Total";
             i18n["Send an email to {0}"] = "Envoyer un email à {0}";
             i18n["Send an email to the {0}"] = "Envoyer un email à la liste {0}";

Modified: web/doc-editor/trunk/js/ui/component/StaleFileGrid.js
===================================================================
--- web/doc-editor/trunk/js/ui/component/StaleFileGrid.js	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/js/ui/component/StaleFileGrid.js	2009-12-14 21:28:16 UTC (rev 292141)
@@ -34,9 +34,6 @@
             }, {
                 name    : 'needCommitLang',
                 mapping : 'needCommitLang'
-            }, {
-                name    : 'isCritical',
-                mapping : 'isCritical'
             }
         ])
     ),
@@ -65,9 +62,6 @@
         if (record.data.needCommitEN || record.data.needCommitLang) {
             return 'file-need-commit';
         }
-        if (record.data.isCritical) {
-            return 'file-critical';
-        }
     },
     emptyText : '<div style="text-align: center;">' + _('No Files') + '</div>'
 });

Modified: web/doc-editor/trunk/js/ui/component/SummaryGrid.js
===================================================================
--- web/doc-editor/trunk/js/ui/component/SummaryGrid.js	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/js/ui/component/SummaryGrid.js	2009-12-14 21:28:16 UTC (rev 292141)
@@ -43,11 +43,9 @@
             {
                 switch (record.id) {
                     case 1: record.set('libel', _('Up to date files'));                break;
-                    case 2: record.set('libel', _('Old files'));                       break;
-                    case 3: record.set('libel', _('Critical files'));                  break;
-                    case 4: record.set('libel', _('Files without revision tag'));      break;
-                    case 5: record.set('libel', _('Files available for translation')); break;
-                    case 6: record.set('libel', _('Total'));                           break;
+                    case 2: record.set('libel', _('Stale files'));                     break;
+                    case 3: record.set('libel', _('Files available for translation')); break;
+                    case 4: record.set('libel', _('Total'));                           break;
                     default: record.set('libel', '');                                  break;
                 }
                 record.commit();
@@ -96,7 +94,6 @@
             case 2: return 'summary_2';
             case 3: return 'summary_3';
             case 4: return 'summary_4';
-            case 5: return 'summary_5';
             default: return '';
         }
     }
@@ -120,13 +117,13 @@
         {
             var id = grid.store.getAt(rowIndex).data.id;

-            // Up to date files, Old files, Criticals files
-            if( id === 1 || id === 2 || id === 3) {
+            // Stales files
+            if( id === 2 ) {
                 Ext.getCmp('acc-need-update').expand();
             }

             // Available for translation
-            if( id === 5 ) {
+            if( id === 3 ) {
                 Ext.getCmp('acc-need-translate').expand();
             }
         }

Modified: web/doc-editor/trunk/js/ui/component/TranslationGraph.js
===================================================================
--- web/doc-editor/trunk/js/ui/component/TranslationGraph.js	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/js/ui/component/TranslationGraph.js	2009-12-14 21:28:16 UTC (rev 292141)
@@ -37,8 +37,8 @@
 {
     if (!ui.component._TranslationGraph.instance) {
         if (!config) {
-			config = {};
-		}
+            config = {};
+        }
         ui.component._TranslationGraph.instance = new ui.component.TranslationGraph(config);
     }
     return ui.component._TranslationGraph.instance;

Modified: web/doc-editor/trunk/js/ui/component/TranslatorGrid.js
===================================================================
--- web/doc-editor/trunk/js/ui/component/TranslatorGrid.js	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/js/ui/component/TranslatorGrid.js	2009-12-14 21:28:16 UTC (rev 292141)
@@ -34,14 +34,10 @@
                 mapping : 'uptodate',
                 type    : 'int'
             }, {
-                name    : 'old',
-                mapping : 'old',
+                name    : 'stale',
+                mapping : 'stale',
                 type    : 'int'
             }, {
-                name    : 'critical',
-                mapping : 'critical',
-                type    : 'int'
-            }, {
                 name    : 'sum',
                 mapping : 'sum',
                 type    : 'int'
@@ -56,7 +52,7 @@
 {
     if (value) {
         var v = (value === 0 || value > 1) ? value : 1;
-        return '(' + v + ' Translators)';
+        return String.format('('+_('{0} Translators')+')', v);
     } else {
         return;
     }
@@ -72,15 +68,9 @@
     }
 };

-// TranslatorGrid cell renderer for old/sum column
-ui.component._TranslatorGrid.old_sumRenderer = function(value)
+// TranslatorGrid cell renderer for stale column
+ui.component._TranslatorGrid.staleRenderer = function(value)
 {
-    return (value === '0') ? '' : value;
-};
-
-// TranslatorGrid cell renderer for critical column
-ui.component._TranslatorGrid.criticalRenderer = function(value)
-{
     if (value === '0') {
         return;
     } else {
@@ -88,6 +78,12 @@
     }
 };

+// TranslatorGrid cell renderer for sum column
+ui.component._TranslatorGrid.sumRenderer = function(value)
+{
+    return (value === '0') ? '' : value;
+};
+
 // TranslatorGrid columns definition
 ui.component._TranslatorGrid.columns = [
     new Ext.grid.RowNumberer(), {
@@ -120,24 +116,17 @@
         dataIndex   : 'uptodate',
         summaryType : 'sum'
     }, {
-        header      : _('Old'),
-        width       : 45,
+        header      : _('Stale'),
+        width       : 90,
         sortable    : true,
-        renderer    : ui.component._TranslatorGrid.old_sumRenderer,
-        dataIndex   : 'old',
+        renderer    : ui.component._TranslatorGrid.staleRenderer,
+        dataIndex   : 'stale',
         summaryType : 'sum'
     }, {
-        header      : _('Critical'),
-        width       : 60,
-        sortable    : true,
-        renderer    : ui.component._TranslatorGrid.criticalRenderer,
-        dataIndex   : 'critical',
-        summaryType : 'sum'
-    }, {
         header      : _('Sum'),
         width       : 50,
         sortable    : true,
-        renderer    : ui.component._TranslatorGrid.old_sumRenderer,
+        renderer    : ui.component._TranslatorGrid.sumRenderer,
         dataIndex   : 'sum',
         summaryType : 'sum'
     }
@@ -219,8 +208,8 @@
 {
     if (!ui.component._TranslatorGrid.instance) {
         if (!config) {
-			config = {};
-		}
+            config = {};
+        }
         ui.component._TranslatorGrid.instance = new ui.component.TranslatorGrid(config);
     }
     return ui.component._TranslatorGrid.instance;

Modified: web/doc-editor/trunk/php/ExtJsController.php
===================================================================
--- web/doc-editor/trunk/php/ExtJsController.php	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/php/ExtJsController.php	2009-12-14 21:28:16 UTC (rev 292141)
@@ -142,6 +142,10 @@
             // Parse translators
             $rm->updateTranslatorInfo();

+            // We re-compute statistics
+            TranslationStatistic::getInstance()->computeSummary('all');
+            TranslatorStatistic::getInstance()->computeSummary('all');
+
             // Set lastUpdate date/time
             $rm->setLastUpdate();
         }
@@ -295,7 +299,7 @@
     {
         AccountManager::getInstance()->isLogged();

-        $translators = TranslatorStatistic::getInstance()->getSummary();
+        $translators = RepositoryFetcher::getInstance()->getStaticValue('translator_summary', AccountManager::getInstance()->vcsLang);

         return JsonResponseBuilder::success(
             array(
@@ -312,7 +316,7 @@
     {
         AccountManager::getInstance()->isLogged();

-        $summary = TranslationStatistic::getInstance()->getSummary();
+        $summary = RepositoryFetcher::getInstance()->getStaticValue('translation_summary', AccountManager::getInstance()->vcsLang);

         return JsonResponseBuilder::success(
             array(
@@ -905,6 +909,10 @@
             // Manage log message (add new or ignore it if this message already exist for this user)
             LogManager::getInstance()->addCommitLog($logMessage);

+            // We re-compute summary statistics for the global documentation & by translators
+            $lang = AccountManager::getInstance()->vcsLang;
+            TranslationStatistic::getInstance()->computeSummary($lang);
+            TranslatorStatistic::getInstance()->computeSummary($lang);
         }

         // Remove the lock File
@@ -1174,30 +1182,18 @@
      */
     public function translationGraph()
     {
-        require_once './jpgraph/src/jpgraph.php';
-        require_once './jpgraph/src/jpgraph_pie.php';
-        require_once './jpgraph/src/jpgraph_pie3d.php';
+        error_reporting(0);

+        require_once dirname(__FILE__) . '/jpgraph/src/jpgraph.php';
+        require_once dirname(__FILE__) . '/jpgraph/src/jpgraph_pie.php';
+        require_once dirname(__FILE__) . '/jpgraph/src/jpgraph_pie3d.php';
+
         AccountManager::getInstance()->isLogged();
+        $lang = AccountManager::getInstance()->vcsLang;

-        $Total_files_lang = TranslationStatistic::getInstance()->getFileCount();
-        $Total_files_lang = $Total_files_lang[0];
-        //
-        $up_to_date = TranslationStatistic::getInstance()->getTransFileCount();
-        $up_to_date = $up_to_date[0];
-        //
-        $critical = TranslationStatistic::getInstance()->getCriticalFileCount();
-        $critical = $critical[0];
-        //
-        $old = TranslationStatistic::getInstance()->getOldFileCount();
-        $old = $old[0];
-        //
-        $missing = sizeof(TranslationStatistic::getInstance()->getMissedFileCount());
-        //
-        $no_tag = TranslationStatistic::getInstance()->getNoTagFileCount();
-        $no_tag = $no_tag[0];
-        //
-        $data     = array($up_to_date,$critical,$old,$missing,$no_tag);
+        $summary = RepositoryFetcher::getInstance()->getStaticValue('translation_summary', $lang);
+
+        $data     = array($summary[0]->nbFiles, $summary[1]->nbFiles, $summary[2]->nbFiles);
         $pourcent = array();
         $total    = 0;
         $total    = array_sum($data);
@@ -1206,17 +1202,15 @@
             $pourcent[] = round($valeur * 100 / $total);
         }

-        $noExplode = ($Total_files_lang == $up_to_date) ? 1 : 0;
+        $noExplode = ($total == $summary[0]->nbFiles) ? 1 : 0;

         $legend = array(
-            $pourcent[0] . '%% up to date ('.$up_to_date.')',
-            $pourcent[1] . '%% critical ('.$critical.')',
-            $pourcent[2] . '%% old ('.$old.')',
-            $pourcent[3] . '%% missing ('.$missing.')',
-            $pourcent[4] . '%% without revtag ('.$no_tag.')'
+            $pourcent[0] . "%% up to date (" . $summary[0]->nbFiles . ")",
+            $pourcent[1] . "%% stales (" . $summary[1]->nbFiles . ")",
+            $pourcent[2] . "%% missing (" . $summary[2]->nbFiles . ")"
         );

-        $title = 'PHP : Details for '.ucfirst(AccountManager::getInstance()->vcsLang).' Documentation';
+        $title = 'PHP : Details for '.ucfirst($lang).' Documentation';

         $graph = new PieGraph(530,300);
         $graph->SetShadow();
@@ -1227,7 +1221,7 @@

         $graph->legend->Pos(0.02,0.18,"right","center");

-        $graph->subtitle->Set('(Total: '.$Total_files_lang.' files)');
+        $graph->subtitle->Set('(Total: '.$total.' files)');
         $graph->subtitle->Align('left');
         $graph->subtitle->SetColor('darkred');


Modified: web/doc-editor/trunk/php/RepositoryFetcher.php
===================================================================
--- web/doc-editor/trunk/php/RepositoryFetcher.php	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/php/RepositoryFetcher.php	2009-12-14 21:28:16 UTC (rev 292141)
@@ -135,8 +135,7 @@
                     "en_revision"    => $new_en_revision,
                     "maintainer"     => $new_maintainer,
                     "needCommitEN"   => (isset($m['en'.$a->path.$a->name])) ? true : false,
-                    "needCommitLang" => (isset($m[$vcsLang.$a->path.$a->name])) ? true : false,
-                    "isCritical"     => false
+                    "needCommitLang" => (isset($m[$vcsLang.$a->path.$a->name])) ? true : false
                 );
             } else {
                 $node[] = array(
@@ -147,8 +146,7 @@
                     "en_revision"     => $a->en_revision,
                     "maintainer"      => $a->maintainer,
                     "needCommitEN"    => false,
-                    "needCommitLang"  => false,
-                    "isCritical"      => ( ($a->en_revision - $a->revision >= 10) || $a->size_diff >= 3 || $a->mdate_diff <= -30 ) ? true : false
+                    "needCommitLang"  => false
                 );
             }
         }
@@ -480,6 +478,27 @@

         return $files;
     }
+
+    /**
+     * Get a static value from DB
+     *
+     * @param $type The type of this value
+     * @param $field The name of the field for this value
+     * @return The value.
+     */
+    public function getStaticValue($type, $field) {
+
+        // Save in DB
+        $s = "SELECT id, value FROM staticValue WHERE `type`='".$type."' AND `field`= '".$field."'";
+        $r = DBConnection::getInstance()->query($s);
+
+        if( $r->num_rows == 0 ) {
+            return false;
+        } else {
+            $a = $r->fetch_object();
+            return json_decode($a->value);
+        }
+    }
 }

 ?>

Modified: web/doc-editor/trunk/php/RepositoryManager.php
===================================================================
--- web/doc-editor/trunk/php/RepositoryManager.php	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/php/RepositoryManager.php	2009-12-14 21:28:16 UTC (rev 292141)
@@ -849,6 +849,28 @@
         }
     }

+    /**
+     * Set a static value into DB
+     *
+     * @param $type The type of this value
+     * @param $field The name of the field for this value
+     * @param $value The value. Can be anything who can be store into a SQL TEXT field
+     * @return Nothing.
+     */
+    public function setStaticValue($type, $field, $value) {
+
+        $s = "SELECT id FROM staticValue WHERE `type`='".$type."' AND `field`= '".$field."'";
+        $r = DBConnection::getInstance()->query($s);
+
+        if( $r->num_rows == 0 ) {
+            $s = "INSERT INTO staticValue (`type`, `field`, `value`) VALUES ('".$type."' , '".$field."', '".DBConnection::getInstance()->real_escape_string($value)."')";
+            DBConnection::getInstance()->query($s);
+        } else {
+            $a = $r->fetch_object();
+            $s = "UPDATE staticValue SET `value`= '".DBConnection::getInstance()->real_escape_string($value)."' WHERE `id`='".$a->id."'";
+            DBConnection::getInstance()->query($s);
+        }
+    }
 }

 ?>

Modified: web/doc-editor/trunk/php/TranslationStatistic.php
===================================================================
--- web/doc-editor/trunk/php/TranslationStatistic.php	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/php/TranslationStatistic.php	2009-12-14 21:28:16 UTC (rev 292141)
@@ -2,6 +2,7 @@

 require_once dirname(__FILE__) . '/AccountManager.php';
 require_once dirname(__FILE__) . '/DBConnection.php';
+require_once dirname(__FILE__) . '/RepositoryManager.php';

 class TranslationStatistic
 {
@@ -23,282 +24,228 @@
     /**
      * Get number/size of all files.
      *
-     * @return An indexed array.
+     * @param $lang Can be either 'all' for all availables languages, or one specific language
+     * @return An associated array
      */
-    public function getFileCount()
+    public function getFileCount($lang='all')
     {
+
+        if( $lang == 'all' ) {
+            $where = '';
+            $groupBy = 'GROUP BY `lang`';
+        } else {
+            $where = '`lang` = \''.$lang.'\' AND';
+            $groupBy = '';
+        }
+
         $s = 'SELECT
                     COUNT(*) AS total,
-                    SUM(`size`) AS total_size
+                    SUM(`size`) AS total_size,
+                    `lang`
                 FROM
                     `files`
                 WHERE
-                    `lang` = "' . AccountManager::getInstance()->vcsLang . '" AND
+                    ' . $where . '
                     ( `status` != "NotInEN" OR `status` IS NULL )
-            ';
+                ' . $groupBy . '
+        ';
         $res = DBConnection::getInstance()->query($s);

-        $r = $res->fetch_array();
-        $result = array($r['total'], $r['total_size']);
+        while( $r = $res->fetch_array() ) {
+            $result[$r['lang']]['total']      = $r['total'];
+            $result[$r['lang']]['total_size'] = $r['total_size'];
+        }
         return $result;
     }

     /**
      * Get number of translated files.
      *
-     * @return Number of translated files.
+     * @param $lang Can be either 'all' for all availables languages, or one specific language
+     * @return An associated array
      */
-    public function getTransFileCount()
+    public function getTransFileCount($lang='all')
     {
+
+        if( $lang == 'all' ) {
+            $where = '';
+            $groupBy = 'GROUP BY `lang`';
+        } else {
+            $where = '`lang` = \''.$lang.'\' AND';
+            $groupBy = '';
+        }
+
         $s = 'SELECT
-                COUNT(name) AS total,
-                SUM(size)   AS total_size
+                COUNT(`name`) AS total,
+                SUM(`size`)   AS total_size,
+                `lang`
             FROM
                 files
             WHERE
-                lang="' . AccountManager::getInstance()->vcsLang . '"
-            AND
-                revision = en_revision';
+                ' . $where . '
+                revision = en_revision
+            ' . $groupBy . '
+        ';
         $res = DBConnection::getInstance()->query($s);

-        $r = $res->fetch_array();
-        $result = array($r['total'], $r['total_size']);
+        while( $r = $res->fetch_array() ) {
+            $result[$r['lang']]['total']      = $r['total'];
+            $result[$r['lang']]['total_size'] = $r['total_size'];
+        }
         return $result;
     }

     /**
-     * Get statistic about critical files which need to be updated.
+     * Get statistic about stales files which need to be updated.
      *
-     * @return An associated array (total=>nb files, total_size=>size of this files).
+     * @param $lang Can be either 'all' for all availables languages, or one specific language
+     * @return An associated array
      */
-    public function getCriticalFileCount()
+    public function getStaleFileCount($lang='all')
     {
-        $s = 'SELECT
-                COUNT(`name`) AS total,
-                SUM(`size`) AS total_size
-            FROM
-                `files`
-            WHERE
-                `lang`="' . AccountManager::getInstance()->vcsLang . '"
-            AND
-                ( `en_revision` - `revision` >= 10  OR
-                ( `en_revision` != `revision`  AND
-                    ( `size_diff` >= 3 OR `mdate_diff` <= -30 )
-                ))
-            AND
-                `size` is not NULL';
-        $result = DBCOnnection::getInstance()->query($s);

-        $r = $result->fetch_array();
-        $result = array($r['total'], $r['total_size']);
-        return $result;
-    }
+        if( $lang == 'all' ) {
+            $where = '';
+            $groupBy = 'GROUP BY `lang`';
+        } else {
+            $where = '`lang` = \''.$lang.'\' AND';
+            $groupBy = '';
+        }

-    /**
-     * Get statistic about old files which need to be uptadeted from LANG tree.
-     *
-     * @return An associated array (total=>nb files, total_size=>size of this files).
-     */
-    public function getOldFileCount()
-    {
         $s = 'SELECT
                 COUNT(`name`) AS total,
-                SUM(`size`)   AS total_size
+                SUM(`size`) AS total_size,
+                `lang`
             FROM
                 `files`
             WHERE
-                `lang`="' . AccountManager::getInstance()->vcsLang . '"
+                ' . $where . '
+                `en_revision` != `revision`
             AND
-                `en_revision` != `revision`
-            AND
-                `en_revision` - `revision` < 10
-            AND
-                `size_diff` < 3
-            AND
-                `mdate_diff` > -30
-            AND
-                `size` is not NULL';
-        $result = DBConnection::getInstance()->query($s);
+                `size` is not NULL
+            ' . $groupBy . '
+        ';
+        $res = DBCOnnection::getInstance()->query($s);

-        $r = $result->fetch_array();
-        $result = array($r['total'], $r['total_size']);
+        while( $r = $res->fetch_array() ) {
+            $result[$r['lang']]['total']      = $r['total'];
+            $result[$r['lang']]['total_size'] = $r['total_size'];
+        }
         return $result;
     }

     /**
      * Get statistic about files which need to be translated.
      *
-     * @return An associated array (total=>nb files, size=>size of this files).
+     * @param $lang Can be either 'all' for all availables languages, or one specific language
+     * @return An associated array
      */
-    public function getNoTransFileCount()
+    public function getNoTransFileCount($lang='all')
     {
-        $s = 'SELECT
-                COUNT(a.name) as total,
-                sum(b.size) as size
-            FROM
-                `files` a
-            LEFT JOIN
-                `files` b
-            ON
-                a.path = b.path
-            AND
-                a.name = b.name
-            WHERE
-                a.lang="' . AccountManager::getInstance()->vcsLang . '"
-            AND
-                b.lang="en"
-            AND
-                a.revision is NULL
-            AND
-                a.size is NULL';
-        $result = DBConnection::getInstance()->query($s);

-        if ($result->num_rows) {
-            $r = $result->fetch_array();
-            return array($r['total'], $r['size']);
+        if( $lang == 'all' ) {
+            $where = '`lang` != \'en\' AND';
         } else {
-            return array(0,0);
+            $where = '`lang` = \''.$lang.'\' AND';
         }
-    }

-    /**
-     * Get count of missed files which need to be added to LANG tree.
-     *
-     * @return An array of missed files (size=>size of the file, file=>name of the file).
-     */
-    public function getMissedFileCount()
-    { // TODO merge with getNoTransFileCount
-        $s = 'SELECT
-                b.size as size,
-                a.name as file
-            FROM
-                `files` a
-            LEFT JOIN
-                `files` b
-            ON
-                a.path = b.path
-            AND
-                a.name = b.name
-            WHERE
-                a.lang="' . AccountManager::getInstance()->vcsLang . '"
-            AND
-                b.lang="en"
-            AND
-                a.revision is NULL
-            AND
-                a.size is NULL';
-        $result = DBConnection::getInstance()->query($s);
+        // We get EN files

-        if ($result->num_rows == 0) {
-            // only 'null' will produce a 0 with sizeof()
-            return null;
-        } else {
-            $tmp = array();
-            while ($r = $result->fetch_array()) {
-                $tmp[] = array('size' => $r['size'], 'file' => $r['file']);
-            }
-            return $tmp;
-        }
-    }
+       $s = 'SELECT * FROM files WHERE lang=\'en\'';

-    /**
-     * Get count of files which haven't revcheck's tags.
-     *
-     * @return An associated array (total=>nb files, size=>size of this files).
-     */
-    public function getNoTagFileCount()
-    {
-        $s = 'SELECT
-                COUNT(a.name) as total,
-                sum(b.size) as size
-            FROM
-                `files` a
-            LEFT JOIN
-                `files` b
-            ON
-                a.path = b.path
-            AND
-                a.name = b.name
-            WHERE
-                a.lang="' . AccountManager::getInstance()->vcsLang . '"
-            AND
-                b.lang="en"
-            AND
-                a.revision is NULL
-            AND
-                a.size is not NULL';
-        $result = DBConnection::getInstance()->query($s);
+       $r = DBConnection::getInstance()->query($s);

-        $r = $result->fetch_array();
-        $result = array($r['total'], $r['size']);
-        return $result;
+       while( $a = $r->fetch_object() ) {
+          $resultEN[$a->path.$a->name] = $a->size;
+       }
+
+       $s = 'SELECT
+                 path, name, lang
+             FROM
+                 files
+             WHERE
+                 ' . $where . '
+                 revision is NULL AND
+                 size is NULL AND
+                 ( `status` != "NotInEN" OR `status` IS NULL )
+       ';
+
+       $r = DBConnection::getInstance()->query($s);
+
+       while( $a = $r->fetch_object() ) {
+          $result[$a->lang][$a->path.$a->name] = 'exist';
+       }
+
+       while( list($a, $b) = each($result) ) {
+           $size[$a] = 0;
+           while( list($k, $v) = each($result[$a]) ) {
+               $size[$a] += $resultEN[$k];
+           }
+       }
+
+       //
+       reset($result);
+       while( list($a, $b) = each($result) ) {
+           $summary[$a]['total'] = count($result[$a]);
+           $summary[$a]['total_size'] = $size[$a];
+       }
+       return $summary;
     }

     /**
-     * Get summary of translation statistic.
+     * Compute summary of translation statistic and store it into DB
      *
-     * @return An indexed array containing summary of statistic
+     * @param $lang Can be either 'all' for all availables languages, or one specific language
      */
-    public function getSummary()
+    public function computeSummary($lang='all')
     {
-        $nbFiles = $this->getFileCount();

-        $uptodate = $this->getTransFileCount();
-        $old      = $this->getOldFileCount();
-        $critical = $this->getCriticalFileCount();
+        $nbFiles   = $this->getFileCount($lang);
+        $uptodate  = $this->getTransFileCount($lang);
+        $stale     = $this->getStaleFileCount($lang);
+        $missFiles = $this->getNoTransFileCount($lang);

-        $missFiles = $this->getNoTransFileCount();
+        if( $lang == 'all' ) {
+            $hereLang = RepositoryManager::getInstance()->availableLang;
+        } else {
+            $hereLang = array($lang);
+        }

-        $withoutRevTag = $this->getNoTagFileCount();
+        foreach( $hereLang as $lang ) {

-        $nbFiles[1] = $uptodate[1]+$old[1]+$critical[1]+$withoutRevTag[1]+$missFiles[1];
+            $summary = array();

-        $summary = array();
+            $summary[0]['id']            = 1;
+            $summary[0]['libel']         = 'Up to date files';
+            $summary[0]['nbFiles']       = $uptodate[$lang]['total'];
+            $summary[0]['percentFiles']  = round(($uptodate[$lang]['total']*100)/$nbFiles[$lang]['total'], 2);
+            $summary[0]['sizeFiles']     = ($uptodate[$lang]['total_size'] == '' ) ? 0 : $uptodate[$lang]['total_size'];
+            $summary[0]['percentSize']   = (!isset($uptodate[$lang]['total_size'])) ? 0 : round(($uptodate[$lang]['total_size']*100)/$nbFiles[$lang]['total_size'], 2);

-        $summary[0]['id']            = 1;
-        $summary[0]['libel']         = 'Up to date files';
-        $summary[0]['nbFiles']       = $uptodate[0];
-        $summary[0]['percentFiles']  = round(($uptodate[0]*100)/$nbFiles[0], 2);
-        $summary[0]['sizeFiles']     = ($uptodate[1] == '' ) ? 0 : $uptodate[1];
-        $summary[0]['percentSize']   = round(($uptodate[1]*100)/$nbFiles[1], 2);
+            $summary[1]['id']            = 2;
+            $summary[1]['libel']         = 'Stale files';
+            $summary[1]['nbFiles']       = $stale[$lang]['total'];
+            $summary[1]['percentFiles']  = round(($stale[$lang]['total']*100)/$nbFiles[$lang]['total'], 2);
+            $summary[1]['sizeFiles']     = ($stale[$lang]['total_size'] == '' ) ? 0 : $stale[$lang]['total_size'];
+            $summary[1]['percentSize']   = (!isset($stale[$lang]['total_size']) || $stale[$lang]['total_size'] == 0 ) ? 0 : round(($stale[$lang]['total_size']*100)/$nbFiles[$lang]['total_size'], 2);

-        $summary[1]['id']            = 2;
-        $summary[1]['libel']         = 'Old files';
-        $summary[1]['nbFiles']       = $old[0];
-        $summary[1]['percentFiles']  = round(($old[0]*100)/$nbFiles[0], 2);
-        $summary[1]['sizeFiles']     = ($old[1] == '' ) ? 0 : $old[1];
-        $summary[1]['percentSize']   = round(($old[1]*100)/$nbFiles[1], 2);
+            $summary[2]['id']            = 3;
+            $summary[2]['libel']         = 'Files available for translation';
+            $summary[2]['nbFiles']       = $missFiles[$lang]['total'];
+            $summary[2]['percentFiles']  = round(($missFiles[$lang]['total']*100)/$nbFiles[$lang]['total'], 2);
+            $summary[2]['sizeFiles']     = ($missFiles[$lang]['total_size'] == '' ) ? 0 : $missFiles[$lang]['total_size'];
+            $summary[2]['percentSize']   = (!isset($missFiles[$lang]['total_size']) || $missFiles[$lang]['total_size'] == 0 ) ? 0 : round(($missFiles[$lang]['total_size']*100)/$nbFiles[$lang]['total_size'], 2);

-        $summary[2]['id']            = 3;
-        $summary[2]['libel']         = 'Critical files';
-        $summary[2]['nbFiles']       = $critical[0];
-        $summary[2]['percentFiles']  = round(($critical[0]*100)/$nbFiles[0], 2);
-        $summary[2]['sizeFiles']     = ($critical[1] == '' ) ? 0 : $critical[1];
-        $summary[2]['percentSize']   = round(($critical[1]*100)/$nbFiles[1], 2);
+            $summary[3]['id']            = 4;
+            $summary[3]['libel']         = 'Total';
+            $summary[3]['nbFiles']       = $nbFiles[$lang]['total'];
+            $summary[3]['percentFiles']  = '100%';
+            $summary[3]['sizeFiles']     = $nbFiles[$lang]['total_size'];
+            $summary[3]['percentSize']   = '100%';

-
-        $summary[3]['id']            = 4;
-        $summary[3]['libel']         = 'Files without revision tag';
-        $summary[3]['nbFiles']       = $withoutRevTag[0];
-        $summary[3]['percentFiles']  = round(($withoutRevTag[0]*100)/$nbFiles[0], 2);
-        $summary[3]['sizeFiles']     = ($withoutRevTag[1] == '' ) ? 0 : $withoutRevTag[1];
-        $summary[3]['percentSize']   = round(($withoutRevTag[1]*100)/$nbFiles[1], 2);
-
-        $summary[4]['id']            = 5;
-        $summary[4]['libel']         = 'Files available for translation';
-        $summary[4]['nbFiles']       = $missFiles[0];
-        $summary[4]['percentFiles']  = round(($missFiles[0]*100)/$nbFiles[0], 2);
-        $summary[4]['sizeFiles']     = ($missFiles[1] == '' ) ? 0 : $missFiles[1];
-        $summary[4]['percentSize']   = round(($missFiles[1]*100)/$nbFiles[1], 2);
-
-        $summary[5]['id']            = 6;
-        $summary[5]['libel']         = 'Total';
-        $summary[5]['nbFiles']       = $nbFiles[0];
-        $summary[5]['percentFiles']  = '100%';
-        $summary[5]['sizeFiles']     = $nbFiles[1];
-        $summary[5]['percentSize']   = '100%';
-
-        return $summary;
+            // Save $summary into DB
+            RepositoryManager::getInstance()->setStaticValue('translation_summary', $lang, json_encode($summary));
+        }
     }

 }

Modified: web/doc-editor/trunk/php/TranslatorStatistic.php
===================================================================
--- web/doc-editor/trunk/php/TranslatorStatistic.php	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/php/TranslatorStatistic.php	2009-12-14 21:28:16 UTC (rev 292141)
@@ -2,6 +2,7 @@

 require_once dirname(__FILE__) . '/AccountManager.php';
 require_once dirname(__FILE__) . '/DBConnection.php';
+require_once dirname(__FILE__) . '/RepositoryManager.php';

 class TranslatorStatistic
 {
@@ -23,23 +24,34 @@
     /**
      * Get translators information.
      *
-     * @return An associated array containing informations about translators.
+     * @param $lang Can be either 'all' for all availables languages, or one specific language
+     * @return An associated array
      */
-    public function getTranslators()
+    public function getTranslators($lang='all')
     {
-        $s = sprintf(
-            'SELECT `id`, `nick`, `name`, `mail`, `vcs` FROM `translators` WHERE `lang`="%s"',
-            AccountManager::getInstance()->vcsLang
-        );
+        if( $lang == 'all' ) {
+            $where = '';
+        } else {
+            $where = 'WHERE `lang`="'.$lang.'"';
+        }
+
+        $s =  'SELECT
+                 `id`, `nick`, `name`, `mail`, `vcs`, `lang`
+               FROM
+                 `translators`
+               '.$where.'
+        ';
+
         $result = DBConnection::getInstance()->query($s);

         $persons = array();
-        while ($r = $result->fetch_array()) {
-            $persons[$r['nick']] = array(
-                'id'   => $r['id'],
-                'name' => utf8_encode($r['name']),
-                'mail' => $r['mail'],
-                'vcs'  => $r['vcs']
+
+        while ($r = $result->fetch_object()) {
+            $persons[$r->lang][$r->nick] = array(
+                'id'   => $r->id,
+                'name' => utf8_encode($r->name),
+                'mail' => $r->mail,
+                'vcs'  => $r->vcs
             );
         }
         return $persons;
@@ -48,135 +60,112 @@
     /**
      * Get number of uptodate files per translators.
      *
-     * @return An associated array (key=>translator's nick, value=>nb files).
+     * @param $lang Can be either 'all' for all availables languages, or one specific language
+     * @return An associated array
      */
-    public function getUptodateFileCount()
+    public function getUptodateFileCount($lang='all')
     {
-        $s = sprintf(
-            'SELECT
+        if( $lang == 'all' ) {
+            $where = '';
+        } else {
+            $where = '`lang`="'.$lang.'" AND';
+        }
+
+        $s = 'SELECT
                 COUNT(`name`) AS total,
-                `maintainer`
+                `maintainer`,
+                `lang`
             FROM
                 `files`
             WHERE
-                `lang`="%s"
-            AND
+                ' . $where . '
                 `revision` = `en_revision`
             GROUP BY
                 `maintainer`
             ORDER BY
-                `maintainer`',
-            AccountManager::getInstance()->vcsLang
-        );
-        $result = DBConnection::getInstance()->query($s);
+                `maintainer`
+        ';
+        $r = DBConnection::getInstance()->query($s);

-        $tmp = array();
-        while ($r = $result->fetch_array()) {
-            $tmp[$r['maintainer']] = $r['total'];
+        $result = array();
+        while ($a = $r->fetch_object()) {
+            $result[$a->lang][$a->maintainer] = $a->total;
         }
-        return $tmp;
+        return $result;
     }

     /**
      * Get number of old files per translators.
      *
-     * @return An associated array (key=>translator's nick, value=>nb files).
+     * @param $lang Can be either 'all' for all availables languages, or one specific language
+     * @return An associated array
      */
-    public function getOldFileCount()
+    public function getStaleFileCount($lang='all')
     {
-        $s = sprintf(
-            'SELECT
+        if( $lang == 'all' ) {
+            $where = '';
+        } else {
+            $where = '`lang`="'.$lang.'" AND';
+        }
+
+        $s = 'SELECT
                 COUNT(`name`) AS total,
-                `maintainer`
+                `maintainer`,
+                `lang`
             FROM
                 `files`
             WHERE
-                `lang`="%s"
-            AND
+                ' . $where . '
                 `en_revision` != `revision`
             AND
-                `en_revision` - `revision` < 10
-            AND
-                `size_diff` < 3
-            AND
-                `mdate_diff` > -30
-            AND
                 `size` is not NULL
             GROUP BY
                 `maintainer`
             ORDER BY
-                `maintainer`',
-            AccountManager::getInstance()->vcsLang
-        );
-        $result = DBConnection::getInstance()->query($s);
+                `maintainer`
+        ';
+        $r = DBConnection::getInstance()->query($s);

-        $tmp = array();
-        while ($r = $result->fetch_array()) {
-            $tmp[$r['maintainer']] = $r['total'];
+        $result = array();
+        while ($a = $r->fetch_object()) {
+            $result[$a->lang][$a->maintainer] = $a->total;
         }
-        return $tmp;
+        return $result;
     }

     /**
-     * Get number of critical files per translators.
+     * Compute statistics summary about translators and store it into DB
      *
-     * @return An associated array (key=>translator's nick, value=>nb files).
+     * @param $lang Can be either 'all' for all availables languages, or one specific language
      */
-    public function getCriticalFileCount()
+    public function computeSummary($lang='all')
     {
-        $s = sprintf(
-            'SELECT
-                COUNT(`name`) AS total,
-                `maintainer`
-            FROM
-                `files`
-            WHERE
-                `lang`="%s"
-            AND
-                ( `en_revision` - `revision` >= 10  OR
-                ( `en_revision` != `revision`  AND
-                    ( `size_diff` >= 3 OR `mdate_diff` <= -30 )
-                ))
-            AND
-                `size` is not NULL
-            GROUP BY
-                `maintainer`
-            ORDER BY
-                `maintainer`',
-            AccountManager::getInstance()->vcsLang
-        );
-        $result = DBConnection::getInstance()->query($s);

-        $tmp = array();
-        while ($r = $result->fetch_array()) {
-            $tmp[$r['maintainer']] = $r['total'];
+        $translators = $this->getTranslators($lang);
+        $uptodate    = $this->getUptodateFileCount($lang);
+        $stale       = $this->getStaleFileCount($lang);
+
+        if( $lang == 'all' ) {
+            $hereLang = RepositoryManager::getInstance()->availableLang;
+        } else {
+            $hereLang = array($lang);
         }
-        return $tmp;
-    }

-    /**
-     * Get statistics summary about translators.
-     *
-     * @return An indexed array containing statistics about translators (nb uptodate files, nb old files, etc...)
-     */
-    public function getSummary()
-    {
-        $translators = $this->getTranslators();
-        $uptodate    = $this->getUptodateFileCount();
-        $old         = $this->getOldFileCount();
-        $critical    = $this->getCriticalFileCount();
+        foreach( $hereLang as $lang ) {

-        $i=0; $persons=array();
-        foreach ($translators as $nick => $data) {
-            $persons[$i]              = $data;
-            $persons[$i]['nick']      = $nick;
-            $persons[$i]['uptodate']  = isset($uptodate[$nick]) ? $uptodate[$nick] : '0';
-            $persons[$i]['old']       = isset($old[$nick])      ? $old[$nick]      : '0';
-            $persons[$i]['critical']  = isset($critical[$nick]) ? $critical[$nick] : '0';
-            $persons[$i]['sum']       = $persons[$i]['uptodate'] + $persons[$i]['old'] + $persons[$i]['critical'];
-            $i++;
+            $i=0; $persons=array();
+            foreach ($translators[$lang] as $nick => $data) {
+                $persons[$i]              = $data;
+                $persons[$i]['nick']      = $nick;
+                $persons[$i]['uptodate']  = isset($uptodate[$lang][$nick]) ? $uptodate[$lang][$nick] : '0';
+                $persons[$i]['stale']     = isset($stale[$lang][$nick])      ? $stale[$lang][$nick]      : '0';
+                $persons[$i]['sum']       = $persons[$i]['uptodate'] + $persons[$i]['stale'];
+                $i++;
+            }
+
+            // Save $summary into DB
+            RepositoryManager::getInstance()->setStaticValue('translator_summary', $lang, json_encode($persons));
         }
-        return $persons;
     }
 }


Modified: web/doc-editor/trunk/scripts/cron/update_data.php
===================================================================
--- web/doc-editor/trunk/scripts/cron/update_data.php	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/scripts/cron/update_data.php	2009-12-14 21:28:16 UTC (rev 292141)
@@ -9,6 +9,8 @@

 require_once dirname(__FILE__) . '/../../php/conf.inc.php';
 require_once dirname(__FILE__) . '/../../php/RepositoryManager.php';
+require_once dirname(__FILE__) . '/../../php/TranslationStatistic.php';
+require_once dirname(__FILE__) . '/../../php/TranslatorStatistic.php';

 $rm = RepositoryManager::getInstance();

@@ -36,6 +38,10 @@
     // Parse translators
     $rm->updateTranslatorInfo();

+    // Compute all summary
+    TranslationStatistic::getInstance()->computeSummary('all');
+    TranslatorStatistic::getInstance()->computeSummary('all');
+
     // Set lastUpdate date/time
     $rm->setLastUpdate();
 }

Modified: web/doc-editor/trunk/themes/style.css
===================================================================
--- web/doc-editor/trunk/themes/style.css	2009-12-14 20:46:58 UTC (rev 292140)
+++ web/doc-editor/trunk/themes/style.css	2009-12-14 21:28:16 UTC (rev 292141)
@@ -333,10 +333,6 @@
 } .file-need-commit {
     color: red !important;
     font-weight: bold !important;
-} .file-critical {
-    color: black !important;
-    font-weight: bold !important;
-    background-color: #fddcdc !important;
 } .summary_1 {
     color: black !important;
     font-weight: bold !important;
@@ -344,19 +340,15 @@
 } .summary_2 {
     color: black !important;
     font-weight: bold !important;
-    background-color: #EEE8AA !important;
+    background-color: #FF6347 !important;
 } .summary_3 {
     color: black !important;
     font-weight: bold !important;
-    background-color: #FF6347 !important;
+    background-color: #EEE8AA !important;
 } .summary_4 {
     color: black !important;
     font-weight: bold !important;
     background-color: #DCDCDC !important;
-} .summary_5 {
-    color: black !important;
-    font-weight: bold !important;
-    background-color: #DCDCDC !important;
 } .diff-content table.code {
     border: 1px solid #ddd;
     border-spacing: 0;
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.