[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Add text search to Special:Drilldown
Yaron Koren has uploaded a new change for review. https://gerrit.wikimedia.org/r/316407 Change subject: Add text search to Special:Drilldown .. Add text search to Special:Drilldown Change-Id: I39240980a36c631f0269d1caaad65a67ce57fd63 --- M drilldown/CargoFilter.php M drilldown/CargoSpecialDrilldown.php M i18n/en.json 3 files changed, 121 insertions(+), 28 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo refs/changes/07/316407/2 diff --git a/drilldown/CargoFilter.php b/drilldown/CargoFilter.php index c77ff11..638cc03 100644 --- a/drilldown/CargoFilter.php +++ b/drilldown/CargoFilter.php @@ -36,7 +36,7 @@ * @param array $appliedFilters * @return string */ - function getTimePeriod( $appliedFilters ) { + function getTimePeriod( $fullTextSearchTerm, $appliedFilters ) { // If it's not a date field, return null. if ( $this->fieldDescription->mType != 'Date' ) { return null; @@ -44,7 +44,7 @@ $cdb = CargoUtils::getDB(); $date_field = $this->name; - list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $appliedFilters ); + list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $fullTextSearchTerm, $appliedFilters ); $res = $cdb->select( $tableNames, array( "MIN($date_field)", "MAX($date_field)" ), $conds, null, null, $joinConds ); $row = $cdb->fetchRow( $res ); @@ -85,12 +85,21 @@ * @param array $appliedFilters * @return array */ - function getQueryParts( $appliedFilters ) { + function getQueryParts( $fullTextSearchTerm, $appliedFilters ) { $cdb = CargoUtils::getDB(); $tableNames = array( $this->tableName ); $conds = array(); $joinConds = array(); + + if ( $fullTextSearchTerm != null ) { + list( $curTableNames, $curConds, $curJoinConds ) = + CargoDrilldownPage::getFullTextSearchQueryParts( $fullTextSearchTerm, $this->tableName, $this->searchableFiles ); + $tableNames = array_merge( $tableNames, $curTableNames ); + $conds = array_merge( $conds, $curConds ); + $joinConds = array_merge( $joinConds, $curJoinConds ); + } + foreach ( $appliedFilters as $af ) { $conds[] = $af->checkSQL(); if ( $af->filter->fieldDescription->mIsList ) { @@ -110,7 +119,7 @@ * @param array $appliedFilters * @return array */ - function getTimePeriodValues( $appliedFilters ) { + function getTimePeriodValues( $fullTextSearchTerm, $appliedFilters ) { $possible_dates = array(); $date_field = $this->name; $timePeriod = $this->getTimePeriod( $fullTextSearchTerm, $appliedFilters ); @@ -125,7 +134,7 @@ $fields = "YEAR($date_field)"; } - list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $appliedFilters ); + list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $fullTextSearchTerm, $appliedFilters ); $selectOptions = array( 'GROUP BY' => $fields, 'ORDER BY' => $fields ); $cdb = CargoUtils::getDB(); $res = $cdb->select( $tableNames, array( $fields, 'COUNT(*)' ), $conds, null, $selectOptions, @@ -169,10 +178,10 @@ * @param array $appliedFilters * @return array */ - function getAllValues( $appliedFilters ) { + function getAllValues( $fullTextSearchTerm, $appliedFilters ) { $cdb = CargoUtils::getDB(); - list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $appliedFilters ); + list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $fullTextSearchTerm, $appliedFilters ); if ( $this->fieldDescription->mIsList ) { $fieldTableName = $this->tableName . '__' . $this->name; $tableNames[] = $fieldTableName; diff --git a/drilldown/CargoSpecialDrilldown.php b/drilldown/CargoSpecialDrilldown.php index f5c7243..0c51958 100644 --- a/drilldown/CargoSpecialDrilldown.php +++ b/drilldown/CargoSpecialDrilldown.php @@ -18,7 +18,7 @@ } function execute( $query ) { - global $cgScriptPath; + global $cgScriptPath, $wgCargoPageDataColumns; $request = $this->getRequest(); $out = $this->getOutput(); @@ -63,6 +63,15 @@ $tableSchemas = CargoUtils::getTableSchemas( array( $tableName ) ); $all_filters = array();
[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Add text search to Special:Drilldown
jenkins-bot has submitted this change and it was merged. Change subject: Add text search to Special:Drilldown .. Add text search to Special:Drilldown Change-Id: I39240980a36c631f0269d1caaad65a67ce57fd63 --- M drilldown/CargoFilter.php M drilldown/CargoSpecialDrilldown.php M i18n/en.json M i18n/qqq.json 4 files changed, 123 insertions(+), 28 deletions(-) Approvals: Yaron Koren: Looks good to me, approved jenkins-bot: Verified diff --git a/drilldown/CargoFilter.php b/drilldown/CargoFilter.php index c77ff11..638cc03 100644 --- a/drilldown/CargoFilter.php +++ b/drilldown/CargoFilter.php @@ -36,7 +36,7 @@ * @param array $appliedFilters * @return string */ - function getTimePeriod( $appliedFilters ) { + function getTimePeriod( $fullTextSearchTerm, $appliedFilters ) { // If it's not a date field, return null. if ( $this->fieldDescription->mType != 'Date' ) { return null; @@ -44,7 +44,7 @@ $cdb = CargoUtils::getDB(); $date_field = $this->name; - list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $appliedFilters ); + list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $fullTextSearchTerm, $appliedFilters ); $res = $cdb->select( $tableNames, array( "MIN($date_field)", "MAX($date_field)" ), $conds, null, null, $joinConds ); $row = $cdb->fetchRow( $res ); @@ -85,12 +85,21 @@ * @param array $appliedFilters * @return array */ - function getQueryParts( $appliedFilters ) { + function getQueryParts( $fullTextSearchTerm, $appliedFilters ) { $cdb = CargoUtils::getDB(); $tableNames = array( $this->tableName ); $conds = array(); $joinConds = array(); + + if ( $fullTextSearchTerm != null ) { + list( $curTableNames, $curConds, $curJoinConds ) = + CargoDrilldownPage::getFullTextSearchQueryParts( $fullTextSearchTerm, $this->tableName, $this->searchableFiles ); + $tableNames = array_merge( $tableNames, $curTableNames ); + $conds = array_merge( $conds, $curConds ); + $joinConds = array_merge( $joinConds, $curJoinConds ); + } + foreach ( $appliedFilters as $af ) { $conds[] = $af->checkSQL(); if ( $af->filter->fieldDescription->mIsList ) { @@ -110,7 +119,7 @@ * @param array $appliedFilters * @return array */ - function getTimePeriodValues( $appliedFilters ) { + function getTimePeriodValues( $fullTextSearchTerm, $appliedFilters ) { $possible_dates = array(); $date_field = $this->name; $timePeriod = $this->getTimePeriod( $fullTextSearchTerm, $appliedFilters ); @@ -125,7 +134,7 @@ $fields = "YEAR($date_field)"; } - list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $appliedFilters ); + list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $fullTextSearchTerm, $appliedFilters ); $selectOptions = array( 'GROUP BY' => $fields, 'ORDER BY' => $fields ); $cdb = CargoUtils::getDB(); $res = $cdb->select( $tableNames, array( $fields, 'COUNT(*)' ), $conds, null, $selectOptions, @@ -169,10 +178,10 @@ * @param array $appliedFilters * @return array */ - function getAllValues( $appliedFilters ) { + function getAllValues( $fullTextSearchTerm, $appliedFilters ) { $cdb = CargoUtils::getDB(); - list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $appliedFilters ); + list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( $fullTextSearchTerm, $appliedFilters ); if ( $this->fieldDescription->mIsList ) { $fieldTableName = $this->tableName . '__' . $this->name; $tableNames[] = $fieldTableName; diff --git a/drilldown/CargoSpecialDrilldown.php b/drilldown/CargoSpecialDrilldown.php index f5c7243..0c51958 100644 --- a/drilldown/CargoSpecialDrilldown.php +++ b/drilldown/CargoSpecialDrilldown.php @@ -18,7 +18,7 @@ } function execute( $query ) { - global $cgScriptPath; + global $cgScriptPath, $wgCargoPageDataColumns; $request = $this->getRequest(); $out = $this->getOutput(); @@ -63,6 +63,15 @@ $tableSchemas = CargoUtils::getTableSchemas( array( $tableName ) ); $all_filters = array(); + $fullTextSearchTerm