jenkins-bot has submitted this change and it was merged.

Change subject: Trend API: Make sure to return data for current week even with 
zero translations
......................................................................


Trend API: Make sure to return data for current week even with zero translations

The data filling in ApiQueryContentTranslationLanguageTrend was stopping
at last known week with non-zero translation. That causes "Last week"
translation going wrong if accessed using array indexes.

This change makes sure that data is filled including current week, no
matter whether translations (published/in progress/deleted) exist or not.

Bug: T129053
Change-Id: I6b51dc768274952d5a32aed2b450242b6f45e410
---
M api/ApiQueryContentTranslationLanguageTrend.php
1 file changed, 4 insertions(+), 2 deletions(-)

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



diff --git a/api/ApiQueryContentTranslationLanguageTrend.php 
b/api/ApiQueryContentTranslationLanguageTrend.php
index 1fdae20..37dadf3 100644
--- a/api/ApiQueryContentTranslationLanguageTrend.php
+++ b/api/ApiQueryContentTranslationLanguageTrend.php
@@ -55,10 +55,12 @@
                foreach ( $data as $column ) {
                        foreach ( array_keys( $column ) as $date ) {
                                $min = min( $min, strtotime( $date ) );
-                               $max = max( $max, strtotime( $date ) );
                        }
                }
-
+               // We need statistics till the end of the ongoing week.
+               $unix = wfTimestamp( TS_UNIX );
+               $n = 7 - date( 'w', $unix );
+               $max = strtotime( "+$n days", $unix );
                $counts = array();
                foreach ( array_keys( $data ) as $type ) {
                        $counts[$type] = 0;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6b51dc768274952d5a32aed2b450242b6f45e410
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to