Skip to content

Commit 0b302de

Browse files
jenkins-botGerrit Code Review
authored andcommitted
Merge "WLFilters: new 'watchlist activity' filter group"
2 parents 2d2cb5e + c36b831 commit 0b302de

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

includes/specials/SpecialWatchlist.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,47 @@ protected function transformFilterDefinition( array $filterDefinition ) {
142142
protected function registerFilters() {
143143
parent::registerFilters();
144144

145+
$this->registerFilterGroup( new ChangesListStringOptionsFilterGroup( [
146+
'name' => 'watchlistactivity',
147+
'title' => 'rcfilters-filtergroup-watchlistactivity',
148+
'class' => ChangesListStringOptionsFilterGroup::class,
149+
'priority' => 3,
150+
'isFullCoverage' => true,
151+
'filters' => [
152+
[
153+
'name' => 'unseen',
154+
'label' => 'rcfilters-filter-watchlistactivity-unseen-label',
155+
'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
156+
'cssClassSuffix' => 'watchedunseen',
157+
'isRowApplicableCallable' => function ( $ctx, $rc ) {
158+
$changeTs = $rc->getAttribute( 'rc_timestamp' );
159+
$lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
160+
return $changeTs >= $lastVisitTs;
161+
},
162+
],
163+
[
164+
'name' => 'seen',
165+
'label' => 'rcfilters-filter-watchlistactivity-seen-label',
166+
'description' => 'rcfilters-filter-watchlistactivity-seen-description',
167+
'cssClassSuffix' => 'watchedseen',
168+
'isRowApplicableCallable' => function ( $ctx, $rc ) {
169+
$changeTs = $rc->getAttribute( 'rc_timestamp' );
170+
$lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
171+
return $changeTs < $lastVisitTs;
172+
}
173+
],
174+
],
175+
'default' => ChangesListStringOptionsFilterGroup::NONE,
176+
'queryCallable' => function ( $specialPageClassName, $context, $dbr,
177+
&$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
178+
if ( $selectedValues === [ 'seen' ] ) {
179+
$conds[] = 'rc_timestamp < wl_notificationtimestamp';
180+
} elseif ( $selectedValues === [ 'unseen' ] ) {
181+
$conds[] = 'rc_timestamp >= wl_notificationtimestamp';
182+
}
183+
}
184+
] ) );
185+
145186
$user = $this->getUser();
146187

147188
$significance = $this->getFilterGroup( 'significance' );

languages/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,11 @@
14301430
"rcfilters-filter-watchlist-watchednew-description": "Changes to Watchlisted pages you haven't visited since the changes occurred.",
14311431
"rcfilters-filter-watchlist-notwatched-label": "Not on Watchlist",
14321432
"rcfilters-filter-watchlist-notwatched-description": "Everything except changes to your Watchlisted pages.",
1433+
"rcfilters-filtergroup-watchlistactivity": "Watchlist activity",
1434+
"rcfilters-filter-watchlistactivity-unseen-label": "Unseen changes",
1435+
"rcfilters-filter-watchlistactivity-unseen-description": "Changes to pages you haven't visited since the changes occurred.",
1436+
"rcfilters-filter-watchlistactivity-seen-label": "Seen changes",
1437+
"rcfilters-filter-watchlistactivity-seen-description": "Changes to pages you have visited since the changes occurred.",
14331438
"rcfilters-filtergroup-changetype": "Type of change",
14341439
"rcfilters-filter-pageedits-label": "Page edits",
14351440
"rcfilters-filter-pageedits-description": "Edits to wiki content, discussions, category descriptions…",

languages/i18n/qqq.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,13 +1613,18 @@
16131613
"rcfilters-filter-minor-description": "Description for the filter for showing edits marked as minor.",
16141614
"rcfilters-filter-major-label": "Label for the filter for showing edits not marked as minor.",
16151615
"rcfilters-filter-major-description": " Description for the filter for showing edits not marked as minor.",
1616-
"rcfilters-filtergroup-watchlist": "Title for the watchlist filter group",
1616+
"rcfilters-filtergroup-watchlist": "Title for the watchlist filter group (only available on [[Special:Recentchanges]])",
16171617
"rcfilters-filter-watchlist-watched-label": "Label for the filter for showing changes to pages on your watchlist.",
16181618
"rcfilters-filter-watchlist-watched-description": "Description for the filter for showing changes to pages on your watchlist.",
16191619
"rcfilters-filter-watchlist-watchednew-label": "Label for the filter for showing new changes to pages on your watchlist.",
16201620
"rcfilters-filter-watchlist-watchednew-description": "Description for the filter for showing new changes to pages on your watchlist.",
16211621
"rcfilters-filter-watchlist-notwatched-label": "Label for the filter for showing changes to pages not on your watchlist.",
16221622
"rcfilters-filter-watchlist-notwatched-description": "Description for the filter for showing changes to pages not on your watchlist.",
1623+
"rcfilters-filtergroup-watchlistactivity": "Title for the watchlist activity filter group (only available on [[Special:Watchlist]])",
1624+
"rcfilters-filter-watchlistactivity-unseen-label": "Label for unseen changes in the watchlist activity filter group.",
1625+
"rcfilters-filter-watchlistactivity-unseen-description": "Description for unseen changes in the watchlist activity filter group.",
1626+
"rcfilters-filter-watchlistactivity-seen-label": "Label for seen changes in the watchlist activity filter group.",
1627+
"rcfilters-filter-watchlistactivity-seen-description": "Description for seen changes in the watchlist activity filter group.",
16231628
"rcfilters-filtergroup-changetype": "Title for the filter group for edit type.",
16241629
"rcfilters-filter-pageedits-label": "Label for the filter for showing edits to existing pages.",
16251630
"rcfilters-filter-pageedits-description": "Description for the filter for showing edits to existing pages.",

0 commit comments

Comments
 (0)