Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | # Reader feedback tags, positive and negative. [a-zA-Z] tag names only. |
218 | 218 | # Each tag has five levels, which 3 being average. The tag names are |
219 | 219 | # mapped to their weight. This is used to determine the "worst"/"best" pages. |
220 | | -$wgFlaggedRevsFeedbackTags = array( 'reliability' => 2, 'completeness' => 2, 'npov' => 1.5, 'presentation' => 1 ); |
| 220 | +$wgFlaggedRevsFeedbackTags = array( 'reliability' => 3, 'completeness' => 2, 'npov' => 2, 'presentation' => 1 ); |
221 | 221 | # How many days back should the average rating for a page be based on? |
222 | 222 | $wgFlaggedRevsFeedbackAge = 7 * 24 * 3600; |
223 | 223 | |
Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php |
— | — | @@ -55,13 +55,20 @@ |
56 | 56 | |
57 | 57 | protected function showForm() { |
58 | 58 | global $wgOut, $wgTitle, $wgScript; |
59 | | - $form = Xml::openElement( 'form', |
60 | | - array( 'name' => 'reviewedpages', 'action' => $wgScript, 'method' => 'get' ) ); |
| 59 | + $form = Xml::openElement( 'form', array( 'name' => 'reviewedpages', 'action' => $wgScript, 'method' => 'get' ) ); |
61 | 60 | $form .= "<fieldset><legend>".wfMsg('ratinghistory-leg')."</legend>\n"; |
62 | 61 | $form .= Xml::hidden( 'title', $wgTitle->getPrefixedDBKey() ); |
63 | 62 | $form .= Xml::hidden( 'target', $this->page->getPrefixedDBKey() ); |
64 | 63 | $form .= $this->getPeriodMenu( $this->period ); |
65 | 64 | $form .= " ".Xml::submitButton( wfMsg( 'go' ) ); |
| 65 | + // Show legend |
| 66 | + $form .= wfMsgExt('ratinghistory-ave',array('parse')); |
| 67 | + $form .= Xml::openElement( 'div', array('class' => 'reader_feedback_legend') ); |
| 68 | + for( $i=0; $i <= 4; $i++) { |
| 69 | + $form .= "<b>[$i]</b> - " . wfMsgHtml( "readerfeedback-level-$i" ); |
| 70 | + $form .= " "; |
| 71 | + } |
| 72 | + $form .= Xml::closeElement( 'div' ); |
66 | 73 | $form .= "</fieldset></form>\n"; |
67 | 74 | $wgOut->addHTML( $form ); |
68 | 75 | } |
— | — | @@ -99,13 +106,6 @@ |
100 | 107 | Xml::openElement( 'img', array('src' => $url,'alt' => $tag) ) . Xml::closeElement( 'img' ) . |
101 | 108 | Xml::closeElement( 'div' ) |
102 | 109 | ); |
103 | | - // Show legend |
104 | | - $wgOut->addHTML( Xml::openElement( 'div', array('class' => 'reader_feedback_legend') ) ); |
105 | | - for( $i=0; $i <= 4; $i++) { |
106 | | - $wgOut->addHTML( " " ); |
107 | | - $wgOut->addHTML( "<b>[$i]</b> - " . wfMsgHtml( "readerfeedback-level-$i" ) ); |
108 | | - } |
109 | | - $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | global $wgPHPlotDir; |
121 | 121 | require_once( "$wgPHPlotDir/phplot.php" ); // load classes |
122 | 122 | // Define the object |
123 | | - $plot = new PHPlot(900,600); |
| 123 | + $plot = new PHPlot(900,400); |
124 | 124 | // Set file path |
125 | 125 | $dir = dirname($filePath); |
126 | 126 | // Make sure directory exists |
— | — | @@ -132,30 +132,45 @@ |
133 | 133 | #$plot->SetTitle("Rating history"); |
134 | 134 | #$plot->SetXTitle('Date'); |
135 | 135 | #$plot->SetYTitle('Daily and running average'); |
| 136 | + $dbr = wfGetDB( DB_SLAVE ); |
| 137 | + // Set cutoff time for period |
| 138 | + $cutoff_unixtime = time() - ($this->period * 24 * 3600); |
| 139 | + $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400); |
| 140 | + $cutoff = $dbr->addQuotes( $dbr->timestamp( $cutoff_unixtime ) ); |
136 | 141 | // Define the data using the DB rows |
137 | 142 | $data = array(); |
138 | 143 | $totalVal = $totalCount = 0; |
139 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 144 | + $lastDay = 31; // init to not trigger first time |
140 | 145 | $res = $dbr->select( 'reader_feedback_history', |
141 | 146 | array( 'rfh_total', 'rfh_count', 'rfh_date' ), |
142 | | - array( 'rfh_page_id' => $this->page->getArticleId(), 'rfh_tag' => $tag ), |
| 147 | + array( 'rfh_page_id' => $this->page->getArticleId(), |
| 148 | + 'rfh_tag' => $tag, |
| 149 | + "rfh_date >= {$cutoff}"), |
143 | 150 | __METHOD__, |
144 | | - array( 'ORDER BY' => 'rfh_date DESC' ) ); |
| 151 | + array( 'ORDER BY' => 'rfh_date ASC' ) ); |
145 | 152 | while( $row = $dbr->fetchObject( $res ) ) { |
146 | 153 | $totalVal += (int)$row->rfh_total; |
147 | 154 | $totalCount += (int)$row->rfh_count; |
148 | 155 | $dayAve = (real)$row->rfh_total/(real)$row->rfh_count; |
149 | 156 | $cumAve = (real)$totalVal/(real)$totalCount; |
150 | | - $month = substr( $row->rfh_date, 4, 2 ); |
151 | | - $day = substr( $row->rfh_date, 6, 2 ); |
| 157 | + $month = intval( substr( $row->rfh_date, 4, 2 ) ); |
| 158 | + $day = intval( substr( $row->rfh_date, 6, 2 ) ); |
| 159 | + # Fill in days with no votes to keep spacing even |
| 160 | + if( $day > ($lastDay + 1) ) { |
| 161 | + for( $i=($lastDay + 1); $i < $day; $i++ ) { |
| 162 | + $data[] = array("{$month}/{$i}",'',''); |
| 163 | + } |
| 164 | + } |
152 | 165 | $data[] = array("{$month}/{$day}",$dayAve,$cumAve); |
| 166 | + $lastDay = $day; |
153 | 167 | } |
154 | 168 | // Flip order |
155 | | - $data = array_reverse($data); |
156 | 169 | $plot->SetDataValues($data); |
157 | 170 | // Turn off X axis ticks and labels because they get in the way: |
158 | 171 | $plot->SetXTickLabelPos('none'); |
159 | 172 | $plot->SetXTickPos('none'); |
| 173 | + $plot->SetYTickIncrement( .5 ); |
| 174 | + $plot->SetPlotAreaWorld( 0, 0, null, 4.5 ); |
160 | 175 | // Draw it! |
161 | 176 | $plot->DrawGraph(); |
162 | 177 | return true; |