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*/; |
2 | 7 | |
| 8 | +-- INSERT INTO /*$wgDBprefix*/article_assessment_ratings(aam_rating) VALUES('blah'); |
| 9 | + |
3 | 10 | -- Store article assessments |
4 | 11 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/article_assessment ( |
5 | 12 | -- Foreign key to page.page_id |
6 | 13 | aa_page_id integer unsigned NOT NULL, |
7 | 14 | -- unique user identifier |
8 | | - aa_user_text varchar(255), |
| 15 | + aa_user_text varchar(255) binary NOT NULL, |
9 | 16 | -- Foreign key to revision.rev_id |
10 | 17 | aa_revision integer unsigned NOT NULL, |
11 | 18 | -- MW Timestamp |
12 | 19 | aa_timestamp binary(14) NOT NULL default '', |
13 | 20 | -- 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, |
18 | 22 | -- 1 vote per user per revision |
19 | 23 | PRIMARY KEY (aa_revision, aa_user_text) |
20 | 24 | ) /*$wgDBTableOptions*/; |
— | — | @@ -22,15 +26,11 @@ |
23 | 27 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/article_assessment_pages ( |
24 | 28 | -- Foreign key to page.page_id |
25 | 29 | 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, |
28 | 32 | -- Sum (total) of all the ratings for this article revision |
29 | 33 | aap_total integer unsigned NOT NULL, |
30 | 34 | -- Number of ratings |
31 | 35 | 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 @@ |
6 | 6 | * @author Nimish Gautam |
7 | 7 | */ |
8 | 8 | $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', |
11 | 11 | ); |
\ No newline at end of file |
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php |
— | — | @@ -16,30 +16,33 @@ |
17 | 17 | $result = $this->getResult(); |
18 | 18 | |
19 | 19 | $this->addTables( 'article_assessment_pages' ); |
| 20 | + $this->addTables( 'article_assessment_ratings' ); |
20 | 21 | |
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' ); |
22 | 25 | |
23 | 26 | if ( isset( $params['pageid'] ) ) { |
24 | 27 | $this->addWhereFld( 'aa_page_id', $params['pageid'] ); |
25 | 28 | } |
26 | 29 | |
27 | | - if ( isset( $params['revid'] ) ) { |
28 | | - $this->addWhereFld( 'aa_revision', $params['revid'] ); |
29 | | - } |
30 | | - |
31 | 30 | $res = $this->select( __METHOD__ ); |
32 | 31 | |
33 | 32 | $assessments = array(); |
34 | 33 | |
35 | 34 | 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, |
40 | 38 | ); |
41 | 39 | } |
42 | 40 | |
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 | + ); |
44 | 47 | } |
45 | 48 | |
46 | 49 | foreach( $assessments as $ass ) { |
— | — | @@ -52,14 +55,12 @@ |
53 | 56 | public function getAllowedParams() { |
54 | 57 | return array( |
55 | 58 | 'pageid' => null, |
56 | | - 'revid' => null, |
57 | 59 | ); |
58 | 60 | } |
59 | 61 | |
60 | 62 | public function getParamDescription() { |
61 | 63 | return array( |
62 | 64 | 'pageid' => '', |
63 | | - 'revid' => '', |
64 | 65 | ); |
65 | 66 | } |
66 | 67 | |
— | — | @@ -71,12 +72,13 @@ |
72 | 73 | |
73 | 74 | public function getPossibleErrors() { |
74 | 75 | return array_merge( parent::getPossibleErrors(), array( |
75 | | - ) ); |
| 76 | + )); |
76 | 77 | } |
77 | 78 | |
78 | 79 | protected function getExamples() { |
79 | 80 | 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' |
81 | 83 | ); |
82 | 84 | } |
83 | 85 | |