Sbisson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/227696

Change subject: [WIP] Flagging and filtering "new pages"
......................................................................

[WIP] Flagging and filtering "new pages"

* Add N next to new pages changes in
  - user contributions
  - recent changes
  - watchlist

* Allow filtering on new pages only

Bug: T93765
Change-Id: Ibe274e2386308f40a34be632ae2d72204ddb8099
---
M includes/Formatter/AbstractQuery.php
M includes/Formatter/Contributions.php
M includes/Formatter/ContributionsQuery.php
M includes/Formatter/RecentChanges.php
M includes/Formatter/RevisionFormatter.php
5 files changed, 38 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/96/227696/1

diff --git a/includes/Formatter/AbstractQuery.php 
b/includes/Formatter/AbstractQuery.php
index 50669d7..b15fdd3 100644
--- a/includes/Formatter/AbstractQuery.php
+++ b/includes/Formatter/AbstractQuery.php
@@ -223,13 +223,23 @@
                if ( $revision instanceof PostRevision ) {
                        $row->rootPost = $this->getRootPost( $revision );
                        $revision->setRootPost( $row->rootPost );
-                       $row->isLastReply = $this->isLastReply( $revision );
+
+                       $replyIds = $this->getAllReplyIds( $revision );
+                       if ( $replyIds ) {
+                               $postId = 
$revision->getPostId()->getAlphadecimal();
+                               $row->isFirstReply = reset( $replyIds ) === 
$postId;
+                               $row->isLastReply = end( $replyIds ) === 
$postId;
+                       }
                }
 
                return $row;
        }
 
-       protected function isLastReply( PostRevision $revision ) {
+       /**
+        * @param PostRevision $revision
+        * @return array|bool
+        */
+       protected function getAllReplyIds( PostRevision $revision ) {
                if ( $revision->isTopicTitle() ) {
                        return false;
                }
@@ -239,8 +249,7 @@
                        return false;
                }
                $parent = 
$this->identityMap[$revision->getReplyToId()->getAlphadecimal()];
-               $keys = array_keys( $parent['children'] );
-               return end( $keys ) === 
$revision->getPostId()->getAlphadecimal();
+               return array_keys( $parent['children'] );
        }
 
        /**
@@ -391,6 +400,8 @@
        public $rootPost;
        /** @var bool */
        public $isLastReply = false;
+       /** @var bool */
+       public $isFirstReply = false;
 
        // protect against typos
        public function __get( $attribute ) {
diff --git a/includes/Formatter/Contributions.php 
b/includes/Formatter/Contributions.php
index b38cab1..dd0670d 100644
--- a/includes/Formatter/Contributions.php
+++ b/includes/Formatter/Contributions.php
@@ -41,6 +41,12 @@
 
                $description = $this->formatDescription( $data, $ctx );
 
+               $flags = '';
+               if ( isset( $data['isNewPage'] ) && $data['isNewPage'] ) {
+                       $flags = ChangesList::flag( 'newpage' );
+                       $flags .= ' ';
+               }
+
                // Put it all together
                return
                        $this->formatTimestamp( $data ) . ' ' .
@@ -48,6 +54,7 @@
                        $separator .
                        $charDiff .
                        $separator .
+                       $flags .
                        $this->getTitleLink( $data, $row, $ctx ) .
                        ( Utils::htmlToPlaintext( $description ) ? $separator . 
$description : '' ) .
                        $this->getHideUnhide( $data, $row, $ctx );
diff --git a/includes/Formatter/ContributionsQuery.php 
b/includes/Formatter/ContributionsQuery.php
index 8b85adb..8145508 100644
--- a/includes/Formatter/ContributionsQuery.php
+++ b/includes/Formatter/ContributionsQuery.php
@@ -172,6 +172,12 @@
                        $conditions['workflow_namespace'] = $pager->namespace;
                }
 
+//             if ( $pager->newOnly ) {
+//                     $condition['rev_type'] = 'post';
+//                     $condition['rev_change_type'] = 'new-post';
+////                   $condition[] = 'rev_parent_id = 0';
+//             }
+
                return $conditions;
        }
 
diff --git a/includes/Formatter/RecentChanges.php 
b/includes/Formatter/RecentChanges.php
index 8b41343..cd03a88 100644
--- a/includes/Formatter/RecentChanges.php
+++ b/includes/Formatter/RecentChanges.php
@@ -46,14 +46,17 @@
 
                $description = $this->formatDescription( $data, $ctx );
 
-               $unpatrolledFlag = '';
+               $flags = '';
+               if ( $row->isFirstReply && $row->revision->isFirstRevision() ) {
+                       $flags .= ChangesList::flag( 'newpage' ) . ' ';
+               }
                if ( ChangesList::isUnpatrolled( $row->recentChange, 
$ctx->getUser() ) ) {
-                       $unpatrolledFlag = ChangesList::flag( 'unpatrolled' ) . 
' ';
+                       $flags .= ChangesList::flag( 'unpatrolled' ) . ' ';
                }
 
                return $this->formatAnchorsAsPipeList( $links, $ctx ) .
                        $separator .
-                       $unpatrolledFlag .
+                       $flags .
                        $this->getTitleLink( $data, $row, $ctx ) .
                        $ctx->msg( 'semicolon-separator' )->escaped() .
                        ' ' .
diff --git a/includes/Formatter/RevisionFormatter.php 
b/includes/Formatter/RevisionFormatter.php
index fa48079..59a65de 100644
--- a/includes/Formatter/RevisionFormatter.php
+++ b/includes/Formatter/RevisionFormatter.php
@@ -285,6 +285,7 @@
                                $res[ApiResult::META_BC_BOOLS],
                                array(
                                        'isMaxThreadingDepth',
+                                       'isNewPage',
                                )
                        );
 
@@ -310,6 +311,9 @@
                                        $row
                                );
                        }
+
+                       $res['isNewPage'] = $row->isFirstReply && 
$row->revision->isFirstRevision();
+
                } elseif ( $row->revision instanceof PostSummary ) {
                        $res['creator'] = $this->serializeUser(
                                $row->revision->getCreatorWiki(),

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe274e2386308f40a34be632ae2d72204ddb8099
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <sbis...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to