Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/195855

Change subject: Stats: If target_url exists, count translation as published
......................................................................

Stats: If target_url exists, count translation as published

If the translation is with draft status and has a target_url it
was published atleast once.

Bug: T92363
Change-Id: Ie2670dc2c99fe1f8fe873aa1d4d4398c012f746f
---
M includes/Translation.php
1 file changed, 52 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/55/195855/1

diff --git a/includes/Translation.php b/includes/Translation.php
index 96ba825..86ade4a 100644
--- a/includes/Translation.php
+++ b/includes/Translation.php
@@ -105,7 +105,20 @@
                );
        }
 
+       /**
+        * Get the stats for all translations in draft or published status
+        */
        public static function getStats() {
+               return array_merge( Translation::getDraftStats(), 
Translation::getPublishedStats() );
+       }
+
+       /**
+        * Get the stats for all translations in draft status and not having
+        * any published URL.
+        * If the translation is with draft status and has a target_url it
+        * was published atleast once.
+        */
+       public static function getDraftStats() {
                $dbr = Database::getConnection( DB_SLAVE );
                $rows = $dbr->select(
                        'cx_translations',
@@ -116,7 +129,45 @@
                                'COUNT(*) AS count',
                                'COUNT(DISTINCT translation_started_by) AS 
translators',
                        ),
-                       '',
+                       array(
+                               "translation_status = 'draft'",
+                               "translation_target_url IS NULL"
+                       ),
+                       __METHOD__,
+                       array(
+                               'GROUP BY' => array(
+                                       'translation_source_language',
+                                       'translation_target_language',
+                                       'translation_status'
+                               ),
+                       )
+               );
+
+               $result = array();
+               foreach ( $rows as $row ) {
+                       $result[] = (array) $row;
+               }
+
+               return $result;
+       }
+
+       /**
+        * Get the stats for all translations in published status or having
+        * a published URL.
+        * If the translation has a target_url it was published atleast once.
+        */
+       public static function getPublishedStats() {
+               $dbr = Database::getConnection( DB_SLAVE );
+               $rows = $dbr->select(
+                       'cx_translations',
+                       array(
+                               'translation_source_language as sourceLanguage',
+                               'translation_target_language as targetLanguage',
+                               "'published' as status",
+                               'COUNT(*) AS count',
+                               'COUNT(DISTINCT translation_started_by) AS 
translators',
+                       ),
+                       array( "translation_status = 'published' OR 
translation_target_url IS NOT NULL" ),
                        __METHOD__,
                        array(
                                'GROUP BY' => array(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2670dc2c99fe1f8fe873aa1d4d4398c012f746f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

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

Reply via email to