Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.sql |
— | — | @@ -4,8 +4,8 @@ |
5 | 5 | aar_rating varchar(255) binary NOT NULL |
6 | 6 | ) /*$wgDBTableOptions*/; |
7 | 7 | |
| 8 | +INSERT INTO /*$wgDBprefix*/article_assessment_ratings(aar_rating) VALUES('articleassessment-rating-wellsourced'), |
| 9 | +('articleassessment-rating-neutrality'), ('articleassessment-rating-completeness'), ('articleassessment-rating-readability'); |
8 | 10 | |
9 | 11 | -- Store article assessments |
10 | 12 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/article_assessment ( |
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php |
— | — | @@ -15,8 +15,7 @@ |
16 | 16 | |
17 | 17 | $result = $this->getResult(); |
18 | 18 | |
19 | | - $this->addTables( 'article_assessment_pages' ); |
20 | | - $this->addTables( 'article_assessment_ratings' ); |
| 19 | + $this->addTables( array( 'article_assessment_pages', 'article_assessment_ratings' ) ); |
21 | 20 | |
22 | 21 | $this->addFields( array( 'aap_page_id', 'aap_total', 'aap_count', 'aap_rating_id', 'aar_rating' ) ); |
23 | 22 | |
— | — | @@ -28,16 +27,18 @@ |
29 | 28 | |
30 | 29 | $res = $this->select( __METHOD__ ); |
31 | 30 | |
32 | | - $assessments = array(); |
| 31 | + $ratings = array(); |
33 | 32 | |
34 | 33 | foreach ( $res as $row ) { |
35 | | - if ( !isset( $assessments[$row->aap_page_id] ) ) { |
36 | | - $assessments[$row->aap_page_id] = array( |
37 | | - 'pageid' => $row->aap_page_id, |
| 34 | + $pageId = $row->aap_page_id; |
| 35 | + |
| 36 | + if ( !isset( $ratings[$pageId] ) ) { |
| 37 | + $ratings[$pageId] = array( |
| 38 | + 'pageid' => $pageId, |
38 | 39 | ); |
39 | 40 | } |
40 | 41 | |
41 | | - $assessments[$row->aap_page_id]['ratings'][$row->aap_rating_id] = array( |
| 42 | + $ratings[$pageId]['ratings'][] = array( |
42 | 43 | 'ratingid' => $row->aap_rating_id, |
43 | 44 | 'ratingdesc' => $row->aar_rating, |
44 | 45 | 'total' => $row->aap_total, |
— | — | @@ -45,9 +46,9 @@ |
46 | 47 | ); |
47 | 48 | } |
48 | 49 | |
49 | | - foreach ( $assessments as $ass ) { |
50 | | - $result->setIndexedTagName( $ass['ratings'], 'r' ); |
51 | | - $result->addValue( array( 'query', $this->getModuleName() ), null, $ass ); |
| 50 | + foreach ( $ratings as $rat ) { |
| 51 | + $result->setIndexedTagName( $rat['ratings'], 'r' ); |
| 52 | + $result->addValue( array( 'query', $this->getModuleName() ), null, $rat ); |
52 | 53 | } |
53 | 54 | |
54 | 55 | $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'aa' ); |