RC Filters: watchlist
authorStephane Bisson <sbisson@wikimedia.org>
Mon, 1 May 2017 20:38:35 +0000 (16:38 -0400)
committerStephane Bisson <sbisson@wikimedia.org>
Tue, 2 May 2017 12:30:29 +0000 (08:30 -0400)
Introducing filtering on watchlist status
  watchlist=watched|watchednew|notwatched

'watchednew' is a subset of 'watched

Bug: T163964
Change-Id: I04df40c8399e15a03a400b4a24afedf1df242a93

includes/specialpage/ChangesListSpecialPage.php
languages/i18n/en.json
languages/i18n/qqq.json

index bc241e0..1b92dc3 100644 (file)
@@ -392,6 +392,95 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                        ],
                                ],
                        ],
+
+                       [
+                               'name' => 'watchlist',
+                               'title' => 'rcfilters-filtergroup-watchlist',
+                               'class' => ChangesListStringOptionsFilterGroup::class,
+                               'isFullCoverage' => true,
+                               'filters' => [
+                                       [
+                                               'name' => 'watched',
+                                               'label' => 'rcfilters-filter-watchlist-watched-label',
+                                               'description' => 'rcfilters-filter-watchlist-watched-description',
+                                               'cssClassSuffix' => 'watched',
+                                               'isRowApplicableCallable' => function ( $ctx, $rc ) {
+                                                       return $rc->getAttribute( 'wl_user' );
+                                               }
+                                       ],
+                                       [
+                                               'name' => 'watchednew',
+                                               'label' => 'rcfilters-filter-watchlist-watchednew-label',
+                                               'description' => 'rcfilters-filter-watchlist-watchednew-description',
+                                               'cssClassSuffix' => 'watchednew',
+                                               'isRowApplicableCallable' => function ( $ctx, $rc ) {
+                                                       return $rc->getAttribute( 'wl_user' ) &&
+                                                               $rc->getAttribute( 'rc_timestamp' ) > $rc->getAttribute( 'wl_notificationtimestamp' );
+                                               },
+                                       ],
+                                       [
+                                               'name' => 'notwatched',
+                                               'label' => 'rcfilters-filter-watchlist-notwatched-label',
+                                               'description' => 'rcfilters-filter-watchlist-notwatched-description',
+                                               'cssClassSuffix' => 'notwatched',
+                                               'isRowApplicableCallable' => function ( $ctx, $rc ) {
+                                                       return $rc->getAttribute( 'wl_user' ) === null;
+                                               },
+                                       ]
+                               ],
+                               'default' => ChangesListStringOptionsFilterGroup::NONE,
+                               'queryCallable' => function ( $specialPageClassName, $context, $dbr,
+                                       &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
+                                       sort( $selectedValues );
+                                       $notwatchedCond = 'wl_user IS NULL';
+                                       $watchedCond = 'wl_user IS NOT NULL';
+                                       $newCond = 'rc_timestamp >= wl_notificationtimestamp';
+
+                                       if ( $selectedValues === [ 'notwatched' ] ) {
+                                               $conds[] = $notwatchedCond;
+                                               return;
+                                       }
+
+                                       if ( $selectedValues === [ 'watched' ] ) {
+                                               $conds[] = $watchedCond;
+                                               return;
+                                       }
+
+                                       if ( $selectedValues === [ 'watchednew' ] ) {
+                                               $conds[] = $dbr->makeList( [
+                                                       $watchedCond,
+                                                       $newCond
+                                               ], LIST_AND );
+                                               return;
+                                       }
+
+                                       if ( $selectedValues === [ 'notwatched', 'watched' ] ) {
+                                               // no filters
+                                               return;
+                                       }
+
+                                       if ( $selectedValues === [ 'notwatched', 'watchednew' ] ) {
+                                               $conds[] = $dbr->makeList( [
+                                                       $notwatchedCond,
+                                                       $dbr->makeList( [
+                                                               $watchedCond,
+                                                               $newCond
+                                                       ], LIST_AND )
+                                               ], LIST_OR );
+                                               return;
+                                       }
+
+                                       if ( $selectedValues === [ 'watched', 'watchednew' ] ) {
+                                               $conds[] = $watchedCond;
+                                               return;
+                                       }
+
+                                       if ( $selectedValues === [ 'notwatched', 'watched', 'watchednew' ] ) {
+                                               // no filters
+                                               return;
+                                       }
+                               },
+                       ],
                ];
 
                $this->reviewStatusFilterGroupDefinition = [
@@ -679,6 +768,11 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                        'rcfilters-hideminor-conflicts-typeofchange',
                        'rcfilters-typeofchange-conflicts-hideminor'
                );
+
+               $watchlistGroup = $this->getFilterGroup( 'watchlist' );
+               $watchlistGroup->getFilter( 'watched' )->setAsSupersetOf(
+                       $watchlistGroup->getFilter( 'watchednew' )
+               );
        }
 
        /**
index 3f5b881..a704d39 100644 (file)
        "rcfilters-filter-minor-description": "Edits the author labeled as minor.",
        "rcfilters-filter-major-label": "Non-minor edits",
        "rcfilters-filter-major-description": "Edits not labeled as minor.",
+       "rcfilters-filtergroup-watchlist": "Watchlisted pages",
+       "rcfilters-filter-watchlist-watched-label": "On Watchlist",
+       "rcfilters-filter-watchlist-watched-description": "Changes to pages on your Watchlist.",
+       "rcfilters-filter-watchlist-watchednew-label": "New Watchlist changes",
+       "rcfilters-filter-watchlist-watchednew-description": "Changes to Watchlisted pages you haven't visited since the changes occurred.",
+       "rcfilters-filter-watchlist-notwatched-label": "Not on Watchlist",
+       "rcfilters-filter-watchlist-notwatched-description": "Everything except changes to your Watchlisted pages.",
        "rcfilters-filtergroup-changetype": "Type of change",
        "rcfilters-filter-pageedits-label": "Page edits",
        "rcfilters-filter-pageedits-description": "Edits to wiki content, discussions, category descriptions....",
index 4339f3d..27dc70a 100644 (file)
        "rcfilters-filter-minor-description": "Description for the filter for showing edits marked as minor.",
        "rcfilters-filter-major-label": "Label for the filter for showing edits not marked as minor.",
        "rcfilters-filter-major-description": " Description for the filter for showing edits not marked as minor.",
+       "rcfilters-filtergroup-watchlist": "Title for the watchlist filter group",
+       "rcfilters-filter-watchlist-watched-label": "Label for the filter for showing changes to pages on your watchlist.",
+       "rcfilters-filter-watchlist-watched-description": "Description for the filter for showing changes to pages on your watchlist.",
+       "rcfilters-filter-watchlist-watchednew-label": "Label for the filter for showing new changes to pages on your watchlist.",
+       "rcfilters-filter-watchlist-watchednew-description": "Description for the filter for showing new changes to pages on your watchlist.",
+       "rcfilters-filter-watchlist-notwatched-label": "Label for the filter for showing changes to pages not on your watchlist.",
+       "rcfilters-filter-watchlist-notwatched-description": "Description for the filter for showing changes to pages not on your watchlist.",
        "rcfilters-filtergroup-changetype": "Title for the filter group for edit type.",
        "rcfilters-filter-pageedits-label": "Label for the filter for showing edits to existing pages.",
        "rcfilters-filter-pageedits-description": "Description for the filter for showing edits to existing pages.",