r71777 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71776‎ | r71777 | r71778 >
Date:00:56, 27 August 2010
Author:reedy
Status:deferred (Comments)
Tags:
Comment:
prefix of columns should match table name...

Fixup where, and display usage

Fixup the r1, r2 elements etc from r71531
Modified paths:
  • /trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.sql (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.sql
@@ -1,7 +1,7 @@
22 -- Store mapping of i18n key of "rating" to an ID
33 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) binary NOT NULL
 4+ aar_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
 5+ aar_rating varchar(255) binary NOT NULL
66 ) /*$wgDBTableOptions*/;
77
88 -- INSERT INTO /*$wgDBprefix*/article_assessment_ratings(aam_rating) VALUES('articleassessment-rating-wellsourced'),
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php
@@ -18,9 +18,9 @@
1919 $this->addTables( 'article_assessment_pages' );
2020 $this->addTables( 'article_assessment_ratings' );
2121
22 - $this->addFields( array( 'aap_page_id', 'aap_total', 'aap_count', 'aap_rating_id', 'aam_rating' ) );
 22+ $this->addFields( array( 'aap_page_id', 'aap_total', 'aap_count', 'aap_rating_id', 'aar_rating' ) );
2323
24 - $this->addWhereFld( 'aap_rating_id', 'aam_rating_id' );
 24+ $this->addWhere( 'aap_rating_id = aar_id' );
2525
2626 if ( isset( $params['pageid'] ) ) {
2727 $this->addWhereFld( 'aap_page_id', $params['pageid'] );
@@ -37,15 +37,16 @@
3838 );
3939 }
4040
41 - $assessments[$row->aap_page_id]['ratings']['r' . $row->aap_rating] = array(
 41+ $assessments[$row->aap_page_id]['ratings'][$row->aap_rating_id] = array(
4242 'ratingid' => $row->aap_rating_id,
43 - 'ratingdesc' => $row->aam_rating,
 43+ 'ratingdesc' => $row->aar_rating,
4444 'total' => $row->aap_total,
4545 'count' => $row->aap_count
4646 );
4747 }
4848
4949 foreach ( $assessments as $ass ) {
 50+ $result->setIndexedTagName( $ass['ratings'], 'r' );
5051 $result->addValue( array( 'query', $this->getModuleName() ), null, $ass );
5152 }
5253

Follow-up revisions

RevisionCommit summaryAuthorDate
r71816Tidy up sql, enable insert...reedy22:25, 27 August 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r71531Fleshed out ApiListArticleAssessment module...reedy00:19, 24 August 2010

Comments

#Comment by Reedy (talk | contribs)   00:57, 27 August 2010
{
	"query": {
		"articleassessment": [
			{
				"pageid": "1",
				"ratings": {
					"1": {
						"ratingid": "1",
						"ratingdesc": "articleassessment-rating-wellsourced",
						"total": "5",
						"count": "1"
					},
					"2": {
						"ratingid": "2",
						"ratingdesc": "articleassessment-rating-neutrality",
						"total": "5",
						"count": "1"
					},
					"3": {
						"ratingid": "3",
						"ratingdesc": "articleassessment-rating-completeness",
						"total": "5",
						"count": "1"
					},
					"4": {
						"ratingid": "4",
						"ratingdesc": "articleassessment-rating-readability",
						"total": "5",
						"count": "1"
					}
				}
			}
		]
	}
}

Should probably drop out the duplicate id in the inner...

#Comment by Catrope (talk | contribs)   01:02, 27 August 2010

No, you should make it a real array in JSON by using 0..3 not 1..4 as keys.

Status & tagging log