jenkins-bot has submitted this change and it was merged. 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, 58 insertions(+), 1 deletion(-) Approvals: Nikerabbit: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Translation.php b/includes/Translation.php index 96ba825..b6eb894 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,51 @@ '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', + ), + $dbr->makeList( + array( + 'translation_status' => 'published', + 'translation_target_url IS NOT NULL', + ), + LIST_OR + ), __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: merged Gerrit-Change-Id: Ie2670dc2c99fe1f8fe873aa1d4d4398c012f746f Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits