r71684 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71683‎ | r71684 | r71685 >
Date:01:11, 26 August 2010
Author:reedy
Status:deferred
Tags:
Comment:
Change Schema

Update ApiList to match updated schema

Tweak i18n messages
Modified paths:
  • /trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.i18n.php (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.sql (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.sql
@@ -1,19 +1,23 @@
 2+-- Store mapping of i18n key of "rating" to an ID
 3+CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/article_assessment_ratings {
 4+ aam_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
 5+ aam_rating varchar(255),
 6+} /*$wgDBTableOptions*/;
27
 8+-- INSERT INTO /*$wgDBprefix*/article_assessment_ratings(aam_rating) VALUES('blah');
 9+
310 -- Store article assessments
411 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/article_assessment (
512 -- Foreign key to page.page_id
613 aa_page_id integer unsigned NOT NULL,
714 -- unique user identifier
8 - aa_user_text varchar(255),
 15+ aa_user_text varchar(255) binary NOT NULL,
916 -- Foreign key to revision.rev_id
1017 aa_revision integer unsigned NOT NULL,
1118 -- MW Timestamp
1219 aa_timestamp binary(14) NOT NULL default '',
1320 -- Rating info
14 - aa_r1 integer unsigned,
15 - aa_r2 integer unsigned,
16 - aa_m3 integer unsigned,
17 - aa_m4 integer unsigned,
 21+ aa_rating_id int unsigned NOT NULL,
1822 -- 1 vote per user per revision
1923 PRIMARY KEY (aa_revision, aa_user_text)
2024 ) /*$wgDBTableOptions*/;
@@ -22,15 +26,11 @@
2327 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/article_assessment_pages (
2428 -- Foreign key to page.page_id
2529 aap_page_id integer unsigned NOT NULL,
26 - -- Foreign key to revision.rev_id
27 - aap_revision integer unsigned NOT NULL,
 30+ -- Which "rating"
 31+ aap_rating_id integer unsigned NOT NULL,
2832 -- Sum (total) of all the ratings for this article revision
2933 aap_total integer unsigned NOT NULL,
3034 -- Number of ratings
3135 aap_count integer unsigned NOT NULL,
32 - -- Which "rating"
33 - aap_rating integer unsigned NOT NULL,
34 - PRIMARY KEY (aap_page_id, aap_revision, aap_rating)
35 -) /*$wgDBTableOptions*/;
36 -
37 -CREATE INDEX /*i*/revision ON /*_*/article_assessment_pages (aap_revision, aap_page_id, aap_rating);
\ No newline at end of file
 36+ PRIMARY KEY (aap_page_id, aap_rating)
 37+) /*$wgDBTableOptions*/;
\ No newline at end of file
Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.i18n.php
@@ -5,6 +5,6 @@
66 * @author Nimish Gautam
77 */
88 $messages['en'] = array(
9 - 'articleassessment-pilot' => 'Pilot for article assessment',
10 - 'articleassessment-pilot-desc' => 'Article Assessment Pilot version',
 9+ 'articleassessment' => 'Article Assessment',
 10+ 'articleassessment-desc' => 'Article Assessment Pilot version',
1111 );
\ No newline at end of file
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php
@@ -16,30 +16,33 @@
1717 $result = $this->getResult();
1818
1919 $this->addTables( 'article_assessment_pages' );
 20+ $this->addTables( 'article_assessment_ratings' );
2021
21 - $this->addFields( array( 'aa_page_id', 'aa_revision', 'aa_total', 'aa_count', 'aa_rating' ) );
 22+ $this->addFields( array( 'aap_page_id', 'aap_total', 'aap_count', 'aap_rating_id', 'aam_rating' ) );
 23+
 24+ $this->addWhereFld( 'aap_rating_id', 'aam_rating_id' );
2225
2326 if ( isset( $params['pageid'] ) ) {
2427 $this->addWhereFld( 'aa_page_id', $params['pageid'] );
2528 }
2629
27 - if ( isset( $params['revid'] ) ) {
28 - $this->addWhereFld( 'aa_revision', $params['revid'] );
29 - }
30 -
3130 $res = $this->select( __METHOD__ );
3231
3332 $assessments = array();
3433
3534 foreach( $res as $row ) {
36 - if ( !isset( $assessments[$row->aa_revision] ) ) {
37 - $assessments[$row->aa_revision] = array(
38 - 'pageid' => $row->aa_page_id,
39 - 'revisionid' => $row->aa_revision,
 35+ if ( !isset( $assessments[$row->aap_page_id] ) ) {
 36+ $assessments[$row->aap_page_id] = array(
 37+ 'pageid' => $row->aap_page_id,
4038 );
4139 }
4240
43 - $assessments[$row->aa_revision]['ratings']['r' . $row->aa_rating] = array( 'rating' => $row->aa_rating, 'total' => $row->aa_total, 'count' => $row->aa_count );
 41+ $assessments[$row->aap_page_id]['ratings']['r' . $row->aap_rating] = array(
 42+ 'ratingid' => $row->aap_rating_id,
 43+ 'ratingdesc' => $row->aam_rating,
 44+ 'total' => $row->aap_total,
 45+ 'count' => $row->aap_count
 46+ );
4447 }
4548
4649 foreach( $assessments as $ass ) {
@@ -52,14 +55,12 @@
5356 public function getAllowedParams() {
5457 return array(
5558 'pageid' => null,
56 - 'revid' => null,
5759 );
5860 }
5961
6062 public function getParamDescription() {
6163 return array(
6264 'pageid' => '',
63 - 'revid' => '',
6465 );
6566 }
6667
@@ -71,12 +72,13 @@
7273
7374 public function getPossibleErrors() {
7475 return array_merge( parent::getPossibleErrors(), array(
75 - ) );
 76+ ));
7677 }
7778
7879 protected function getExamples() {
7980 return array(
80 - 'api.php?action=query&list=articleassessment'
 81+ 'api.php?action=query&list=articleassessment',
 82+ 'api.php?action=query&list=articleassessment&aapageid=1'
8183 );
8284 }
8385

Status & tagging log