https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113609
Revision: 113609
Author: jeroendedauw
Date: 2012-03-12 03:32:34 +0000 (Mon, 12 Mar 2012)
Log Message:
-----------
optimize courses pager
Modified Paths:
--------------
trunk/extensions/EducationProgram/includes/EPArticleTable.php
trunk/extensions/EducationProgram/includes/EPCoursePager.php
Modified: trunk/extensions/EducationProgram/includes/EPArticleTable.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPArticleTable.php
2012-03-12 03:06:31 UTC (rev 113608)
+++ trunk/extensions/EducationProgram/includes/EPArticleTable.php
2012-03-12 03:32:34 UTC (rev 113609)
@@ -518,9 +518,9 @@
*/
protected function doBatchLookups() {
$userIds = array();
+ $field = $this->table->getPrefixedField( 'org_id' );
while( $student = $this->mResult->fetchObject() ) {
- $field = EPStudents::singleton()->getPrefixedField(
'user_id' );
$userIds[] = $student->$field;
$this->articles[$student->$field] = array();
}
Modified: trunk/extensions/EducationProgram/includes/EPCoursePager.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCoursePager.php
2012-03-12 03:06:31 UTC (rev 113608)
+++ trunk/extensions/EducationProgram/includes/EPCoursePager.php
2012-03-12 03:32:34 UTC (rev 113609)
@@ -20,6 +20,15 @@
* @var boolean
*/
protected $readOnlyMode;
+
+ /**
+ * List of org names, looked up in batch before the rows are displayed.
+ * org id => org name
+ *
+ * @since 0.1
+ * @var array
+ */
+ protected $orgNames;
/**
* Constructor.
@@ -72,15 +81,11 @@
public function getFormattedValue( $name, $value ) {
switch ( $name ) {
case 'name':
- $value = EPCourses::singleton()->getLinkFor(
$value );
+ $value = $this->table->getLinkFor( $value );
break;
case 'org_id':
- $org = EPOrgs::singleton()->selectRow( 'name',
array( 'id' => $value ) );
-
- // This should not happen. A course should
always have an org.
- // But if something gets messed up somehow,
just display the ID rather then throwing a fatal.
- if ( $org !== false ) {
- $value = $org->getLink();
+ if ( array_key_exists( $value, $this->orgNames
) ) {
+ $value =
EPOrgs::singleton()->getLinkFor( $this->orgNames[$value] );
}
break;
case 'term':
@@ -268,4 +273,22 @@
return !$this->readOnlyMode;
}
+ /**
+ * (non-PHPdoc)
+ * @see IndexPager::doBatchLookups()
+ */
+ protected function doBatchLookups() {
+ $orgIds = array();
+ $field = $this->table->getPrefixedField( 'org_id' );
+
+ while( $course = $this->mResult->fetchObject() ) {
+ $orgIds[] = $course->$field;
+ }
+
+ $this->orgNames = EPOrgs::singleton()->selectFields(
+ array( 'id', 'name' ),
+ array( 'id' => $orgIds )
+ );
+ }
+
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs