Ejegg has submitted this change and it was merged.
Change subject: Move subselects into the main pager query (take 2)
......................................................................
Move subselects into the main pager query (take 2)
Make one query rather than a myriad.
Change-Id: I031dde9456116308c02a316145b29ac95fac8370
---
M includes/CNCampaignPager.php
1 file changed, 56 insertions(+), 46 deletions(-)
Approvals:
Ejegg: Looks good to me, approved
diff --git a/includes/CNCampaignPager.php b/includes/CNCampaignPager.php
index 4900aa5..ea2a33f 100644
--- a/includes/CNCampaignPager.php
+++ b/includes/CNCampaignPager.php
@@ -56,54 +56,63 @@
* @see IndexPager::getQueryInfo()
*/
public function getQueryInfo() {
+ $pagerQuery = array(
+ 'tables' => array(
+ 'notices' => 'cn_notices',
+ ),
+ 'fields' => array(
+ 'notices.not_id',
+ 'not_name',
+ 'not_start',
+ 'not_end',
+ 'not_enabled',
+ 'not_preferred',
+ 'not_throttle',
+ 'not_geo',
+ 'not_locked',
+ 'not_archived',
+ $this->getDatabase()->buildGroupConcatField(
+ ',',
+ 'cn_notice_countries',
+ 'nc_country',
+ 'nc_notice_id = notices.not_id'
+ ) . ' AS countries',
+ $this->getDatabase()->buildGroupConcatField(
+ ',',
+ 'cn_notice_languages',
+ 'nl_language',
+ 'nl_notice_id = notices.not_id'
+ ) . ' AS languages',
+ $this->getDatabase()->buildGroupConcatField(
+ ',',
+ 'cn_notice_projects',
+ 'np_project',
+ 'np_notice_id = notices.not_id'
+ ) . ' AS projects',
+ ),
+ 'conds' => array(),
+ );
if ( $this->assignedBannerId ) {
-
- // Query for only campaigns associated with a specific
banner id
- return array(
- 'tables' => array(
- 'notices' => 'cn_notices',
- 'assignments' => 'cn_assignments'
- ),
- 'fields' => array(
- 'notices.not_id',
- 'not_name',
- 'not_start',
- 'not_end',
- 'not_enabled',
- 'not_preferred',
- 'not_throttle',
- 'not_geo',
- 'not_locked',
- 'not_archived'
- ),
- 'conds' => array(
- 'notices.not_id = assignments.not_id',
- 'assignments.tmp_id = ' .
(int)$this->assignedBannerId
- )
- );
-
- } else {
-
- // Query for all campaigns
- return array(
- 'tables' => 'cn_notices',
- 'fields' => array(
- 'not_id',
- 'not_name',
- 'not_start',
- 'not_end',
- 'not_enabled',
- 'not_preferred',
- 'not_throttle',
- 'not_geo',
- 'not_locked',
- 'not_archived'
- ),
- 'conds' => array()
+ // Query for only campaigns associated with a specific
banner id.
+ $pagerQuery['tables']['assignments'] = 'cn_assignments';
+ $pagerQuery['conds'] = array(
+ 'notices.not_id = assignments.not_id',
+ 'assignments.tmp_id = ' .
(int)$this->assignedBannerId
);
}
+
+ return $pagerQuery;
}
+
+ public function doQuery() {
+ // group_concat output is limited to 1024 characters by
default, increase
+ // the limit temporarily so the list of all languages can be
rendered.
+ $this->getDatabase()->query( 'SET SESSION group_concat_max_len
= 10000' );
+
+ parent::doQuery();
+ }
+
/**
* @see TablePager::getFieldNames()
@@ -179,17 +188,18 @@
);
case 'projects':
- $p = Campaign::getNoticeProjects( $name );
+ $p = explode( ',', $this->mCurrentRow->projects
);
return $this->onSpecialCN->listProjects( $p );
case 'languages':
- $l = Campaign::getNoticeLanguages( $name );
+ $l = explode( ',',
$this->mCurrentRow->languages );
return $this->onSpecialCN->listLanguages( $l );
case 'countries':
if ( $this->mCurrentRow->not_geo ) {
- $c = Campaign::getNoticeCountries(
$name );
+ $c = explode( ',',
$this->mCurrentRow->countries );
} else {
+ // FIXME: this is silly.
$c = array_keys(
GeoTarget::getCountriesList( 'en' ) );
}
--
To view, visit https://gerrit.wikimedia.org/r/177758
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I031dde9456116308c02a316145b29ac95fac8370
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits