Index: trunk/extensions/GPoC/GPoC.hooks.php |
— | — | @@ -53,6 +53,7 @@ |
54 | 54 | $base = dirname( __FILE__ ) . '/schema'; |
55 | 55 | $du->addExtensionTable( "ratings", "$base/ratings.sql"); |
56 | 56 | $du->addExtensionTable( "project_stats", "$base/project_stats.sql" ); |
| 57 | + $du->addExtensionTable( "assessment_changelog", "$base/log.sql" ); |
57 | 58 | return true; |
58 | 59 | } |
59 | 60 | } |
Index: trunk/extensions/GPoC/schema/log.sql |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | -- Replace /*_*/ with the proper prefix |
3 | 3 | -- Replace /*$wgDBTableOptions*/ with the correct options |
4 | 4 | |
5 | | -CREATE TABLE IF NOT EXISTS /*_*/log ( |
| 5 | +CREATE TABLE IF NOT EXISTS /*_*/assessment_changelog ( |
6 | 6 | l_project varchar(63) not null, |
7 | 7 | -- project name |
8 | 8 | |
— | — | @@ -14,11 +14,7 @@ |
15 | 15 | l_action varchar(20) character set ascii not null, |
16 | 16 | -- type of log entry (e.g. 'quality') |
17 | 17 | |
18 | | - -- NOTE: this is ASCII because of maximum index key |
19 | | - -- length constraints interacting with utf-8 fields in |
20 | | - -- mysql. The primary key for this table is just under the limit. |
21 | | - |
22 | | - l_timestamp binary(14) not null, |
| 18 | + l_timestamp binary(14) not null, |
23 | 19 | -- timestamp when log entry was added |
24 | 20 | |
25 | 21 | l_old varchar(63), |
— | — | @@ -35,4 +31,4 @@ |
36 | 32 | key (l_article, l_namespace) |
37 | 33 | ) /*$wgDBTableOptions*/; |
38 | 34 | |
39 | | -CREATE INDEX /*i*/l_project ON /*_*/log (l_project); |
| 35 | +CREATE INDEX /*i*/l_project ON /*_*/assessment_changelog (l_project); |
Index: trunk/extensions/GPoC/models/Log.php |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Represents an convenience methods for logging |
| 6 | + **/ |
| 7 | +class AssessmentChangeLog { |
| 8 | + public static function makeEntry( $project, $namespace, $article, $timestamp, $action, $old, $new ) { |
| 9 | + $dbw = wfGetDB( DB_MASTER ); |
| 10 | + $dbw->insert( |
| 11 | + 'assessment_changelog', |
| 12 | + array( |
| 13 | + 'l_project' => $project, |
| 14 | + 'l_namespace' => $namespace, |
| 15 | + 'l_article' => $article, |
| 16 | + 'l_action' => $action, |
| 17 | + 'l_timestamp' => $timestamp, |
| 18 | + 'l_old' => $old, |
| 19 | + 'l_new' => $new, |
| 20 | + 'l_revision_timestamp' => 0 |
| 21 | + ), |
| 22 | + __METHOD__ |
| 23 | + ); |
| 24 | + } |
| 25 | +} |
Property changes on: trunk/extensions/GPoC/models/Log.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 26 | + native |
Index: trunk/extensions/GPoC/models/Rating.php |
— | — | @@ -27,17 +27,46 @@ |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function update( $importance, $quality, $timestamp ) { |
| 31 | + $logAction = ""; // q for quality change, i for importance change, qi for both |
31 | 32 | if( $quality != $this->quality ) { |
32 | 33 | $this->old_quality = $this->quality; |
33 | 34 | $this->quality = $quality; |
34 | 35 | $this->quality_timestamp = $timestamp; |
| 36 | + $logAction .= "q"; |
35 | 37 | } |
36 | 38 | if( $importance != $this->importance ) { |
37 | 39 | $this->old_importance = $this->importance; |
38 | 40 | $this->importance = $importance; |
39 | 41 | $this->importance_timestamp = $timestamp; |
| 42 | + $logAction .= "i"; |
40 | 43 | } |
41 | | - $this->saveAll(); |
| 44 | + if( $logAction != "") { |
| 45 | + $timestamp = wfTimestamp( TS_MW ); |
| 46 | + if( strpos( $logAction, 'q' ) !== false ) { |
| 47 | + AssessmentChangeLog::makeEntry( |
| 48 | + $this->project, |
| 49 | + $this->namespace, |
| 50 | + $this->title, |
| 51 | + $timestamp, |
| 52 | + "quality", |
| 53 | + $this->old_quality, |
| 54 | + $this->quality |
| 55 | + ); |
| 56 | + } |
| 57 | + if( strpos( $logAction, 'i' ) !== false ) { |
| 58 | + AssessmentChangeLog::makeEntry( |
| 59 | + $this->project, |
| 60 | + $this->namespace, |
| 61 | + $this->title, |
| 62 | + $timestamp, |
| 63 | + "importance", |
| 64 | + $this->old_importance, |
| 65 | + $this->importance |
| 66 | + ); |
| 67 | + } |
| 68 | + |
| 69 | + $this->saveAll(); |
| 70 | + } |
42 | 71 | } |
43 | 72 | |
44 | 73 | private function updateAggregateStats( $is_new_rating ) { |
— | — | @@ -123,7 +152,7 @@ |
124 | 153 | |
125 | 154 | $this->updateAggregateStats( true ); |
126 | 155 | $this->inDB = true; |
127 | | - } |
| 156 | + } |
128 | 157 | } |
129 | 158 | |
130 | 159 | public static function forTitle( $title ) { |
Index: trunk/extensions/GPoC/GPoC.php |
— | — | @@ -22,6 +22,7 @@ |
23 | 23 | $wgAutoloadClasses['GPoCHooks'] = $dir . 'GPoC.hooks.php'; |
24 | 24 | $wgAutoloadClasses['Statistics'] = $dir . 'models/Statistics.php'; |
25 | 25 | $wgAutoloadClasses['Rating'] = $dir . 'models/Rating.php'; |
| 26 | +$wgAutoloadClasses['AssessmentChangeLog'] = $dir . 'models/Log.php'; |
26 | 27 | $wgAutoloadClasses['TableDisplay'] = $dir . 'TableDisplay.php'; |
27 | 28 | $wgAutoloadClasses['AssessmentsExtractor'] = $dir . 'AssessmentsExtractor.php'; |
28 | 29 | |