Merge "Allow filtering on newbies in Special:NewFiles"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 15 Jun 2017 17:25:41 +0000 (17:25 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 15 Jun 2017 17:25:41 +0000 (17:25 +0000)
includes/specials/SpecialNewimages.php
includes/specials/pagers/NewFilesPager.php
languages/i18n/en.json
languages/i18n/qqq.json

index 5fa0a73..f7d76a7 100644 (file)
@@ -41,6 +41,7 @@ class SpecialNewFiles extends IncludableSpecialPage {
                $opts->add( 'like', '' );
                $opts->add( 'user', '' );
                $opts->add( 'showbots', false );
+               $opts->add( 'newbies', false );
                $opts->add( 'hidepatrolled', false );
                $opts->add( 'limit', 50 );
                $opts->add( 'offset', '' );
@@ -97,6 +98,12 @@ class SpecialNewFiles extends IncludableSpecialPage {
                                'name' => 'user',
                        ],
 
+                       'newbies' => [
+                               'type' => 'check',
+                               'label-message' => 'newimages-newbies',
+                               'name' => 'newbies',
+                       ],
+
                        'showbots' => [
                                'type' => 'check',
                                'label-message' => 'newimages-showbots',
index cce0323..07e9951 100644 (file)
@@ -74,6 +74,20 @@ class NewFilesPager extends RangeChronologicalPager {
                        }
                }
 
+               if ( $opts->getValue( 'newbies' ) ) {
+                       // newbie = most recent 1% of users
+                       $dbr = wfGetDB( DB_REPLICA );
+                       $max = $dbr->selectField( 'user', 'max(user_id)', false, __METHOD__ );
+                       $conds[] = 'img_user >' . (int)( $max - $max / 100 );
+
+                       // there's no point in looking for new user activity in a far past;
+                       // beyond a certain point, we'd just end up scanning the rest of the
+                       // table even though the users we're looking for didn't yet exist...
+                       // see T140537, (for ContribsPages, but similar to this)
+                       $conds[] = 'img_timestamp > ' .
+                               $dbr->addQuotes( $dbr->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) );
+               }
+
                if ( !$opts->getValue( 'showbots' ) ) {
                        $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
 
index 70664af..e9fb989 100644 (file)
        "newimages-legend": "Filter",
        "newimages-label": "Filename (or a part of it):",
        "newimages-user": "IP address or username",
+       "newimages-newbies": "Show contributions of new accounts only",
        "newimages-showbots": "Show uploads by bots",
        "newimages-hidepatrolled": "Hide patrolled uploads",
        "noimages": "Nothing to see.",
index 0569267..fc8a04a 100644 (file)
        "newimages-legend": "Caption of the fieldset for the filter on [[Special:NewImages]]\n\n{{Identical|Filter}}",
        "newimages-label": "Caption of the filter editbox on [[Special:NewImages]]",
        "newimages-user": "Caption of the username/IP address editbox on [[Special:NewImages]]",
+       "newimages-newbies": "Used as label for a checkbox. When checked, [[Special:NewImages]] will only display uploads by new users.",
        "newimages-showbots": "Used as label for a checkbox. When checked, [[Special:NewImages]] will also display uploads by users in the bots group.",
        "newimages-hidepatrolled": "Used as label for a checkbox. When checked, [[Special:NewImages]] will not display patrolled uploads.\n\nCf. {{msg-mw|tog-hidepatrolled}} and {{msg-mw|apihelp-feedrecentchanges-param-hidepatrolled}}.",
        "noimages": "This is shown on the special page [[Special:NewImages]], when there aren't any recently uploaded files.",