Allow filtering on newbies in Special:NewFiles
authorMatthias Mullie <git@mullie.eu>
Tue, 7 Mar 2017 15:34:43 +0000 (16:34 +0100)
committerMatthias Mullie <mmullie@wikimedia.org>
Thu, 8 Jun 2017 14:08:23 +0000 (14:08 +0000)
Bug: T122354
Change-Id: I4b659a78e70a5102bc8592816160df888e9fc439

includes/specials/SpecialNewimages.php
includes/specials/pagers/NewFilesPager.php
languages/i18n/en.json
languages/i18n/qqq.json

index 583d4f9..bc4eed7 100644 (file)
@@ -42,6 +42,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', '' );
@@ -98,6 +99,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 9fe0e3c..86478e8 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 4d46e6f..f48dfe3 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.",