Santhosh has uploaded a new change for review.

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

Change subject: WIP: Suggestions: Public task lists based on category
......................................................................

WIP: Suggestions: Public task lists based on category

A script to create a suggestion list based on a category. Pages
exist in source and not exist in target language will be added to that
list. There is no UI to create or manage this list. For now just
a maintanance script.

TODO:
* Do not use infinite scroll on these lists.
* Figure out a way to display the title properly for this list
* Collapse these list by default

Bug: T115006
Change-Id: I3eb29a2337f2ddbb2bc9bcf86f8efcfa532b0984
---
M includes/SuggestionList.php
M includes/SuggestionListManager.php
M scripts/manage-lists.php
3 files changed, 34 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/61/247261/1

diff --git a/includes/SuggestionList.php b/includes/SuggestionList.php
index e6baa46..06bcd96 100644
--- a/includes/SuggestionList.php
+++ b/includes/SuggestionList.php
@@ -7,6 +7,7 @@
        const TYPE_FEATURED = 1;
        const TYPE_DISCARDED = 2;
        const TYPE_FAVORITE = 3;
+       const TYPE_CATEGORY_TASKLIST = 4;
 
        protected $id;
        protected $name;
diff --git a/includes/SuggestionListManager.php 
b/includes/SuggestionListManager.php
index 5c4c994..2dbae8c 100644
--- a/includes/SuggestionListManager.php
+++ b/includes/SuggestionListManager.php
@@ -251,7 +251,10 @@
                        'cx_lists',
                        '*',
                        array(
-                               'cxl_type' => SuggestionList::TYPE_FEATURED,
+                               'cxl_type' => array(
+                                       SuggestionList::TYPE_FEATURED,
+                                       SuggestionList::TYPE_CATEGORY_TASKLIST
+                               ),
                                'cxl_public' => true,
                        ),
                        __METHOD__
diff --git a/scripts/manage-lists.php b/scripts/manage-lists.php
index 818b5a8..3ba172e 100644
--- a/scripts/manage-lists.php
+++ b/scripts/manage-lists.php
@@ -50,6 +50,12 @@
                        true,
                        true
                );
+               $this->addOption(
+                       'type',
+                       'Type of the list. Allowed values: (a) featured (b) 
category-tasklist',
+                       true,
+                       true
+               );
        }
 
        public function execute() {
@@ -57,6 +63,7 @@
                $sourceDomain = SiteMapper::getDomainCode( $this->getOption( 
'source' ) );
                $targetDomain = SiteMapper::getDomainCode( $this->getOption( 
'target' ) );
                $category = $this->getOption( 'category' );
+               $type = $this->getOption( 'type' );
 
                if ( $this->dryrun ) {
                        $this->output( "DRY-RUN mode: actions are NOT 
executed\n" );
@@ -70,7 +77,11 @@
                $count = count( $pages );
 
                if ( !$this->dryrun ) {
-                       $this->createFeaturedSuggestions( $pages );
+                       if ( $type === 'featured' ){
+                               $this->createFeaturedSuggestions( $pages );
+                       } elseif ( $type === 'category-tasklist' ) {
+                               $this->createCategoryTaskList( $category, 
$pages );
+                       }
                        $this->output( "$count pages added to the list 
successfully.\n" );
                } else {
                        $this->output( "Found $count pages:\n" );
@@ -136,16 +147,30 @@
 
        protected function createFeaturedSuggestions( $pages ) {
                $featureListName = 'cx-suggestionlist-featured';
+               $type = SuggestionList::TYPE_FEATURED;
+               $this->createPublicList( $featureListName, $type, $pages );
+       }
+
+       protected function createCategoryTaskList( $category, $pages ) {
+               $name = $category;
+               $type = SuggestionList::TYPE_CATEGORY_TASKLIST;
+               $this->createPublicList( $name, $type, $pages );
+       }
+
+       protected function createPublicList( $name, $type, $pages ) {
+               if ( !count( pages ) ) {
+                       return;
+               }
                $sourceLanguage = $this->getOption( 'source' );
                $targetLanguage = $this->getOption( 'target' );
 
                $manager = new SuggestionListManager();
-               $list = $manager->getListByName( $featureListName );
+               $list = $manager->getListByName( $name );
 
                if ( $list === null ) {
                        $list = new SuggestionList( array(
-                               'type' => SuggestionList::TYPE_FEATURED,
-                               'name' => $featureListName,
+                               'type' => $type,
+                               'name' => $name,
                                'public' => true,
                        ) );
                        $listId = $manager->insertList( $list );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3eb29a2337f2ddbb2bc9bcf86f8efcfa532b0984
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

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

Reply via email to