Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js |
— | — | @@ -208,6 +208,11 @@ |
209 | 209 | if ( 'result' in data['articlefeedbackv5-flag-feedback'] ) { |
210 | 210 | if( data['articlefeedbackv5-flag-feedback'].result == 'Success' ) { |
211 | 211 | msg = 'articlefeedbackv5-' + type + '-saved'; |
| 212 | + if( 'helpful' in data['articlefeedbackv5-flag-feedback'] ) { |
| 213 | + |
| 214 | + $( '#articleFeedbackv5-helpful-votes-' + id ).text( data['articlefeedbackv5-flag-feedback'].helpful ); |
| 215 | + |
| 216 | + } |
212 | 217 | } else if (data['articlefeedbackv5-flag-feedback'].result == 'Error' ) { |
213 | 218 | msg = data['articlefeedbackv5-flag-feedback'].reason; |
214 | 219 | } |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
— | — | @@ -27,6 +27,7 @@ |
28 | 28 | $error = null; |
29 | 29 | $dbr = wfGetDB( DB_SLAVE ); |
30 | 30 | $counts = array( 'increment' => array(), 'decrement' => array() ); |
| 31 | + $helpful = null; |
31 | 32 | |
32 | 33 | # load feedback record, bail if we don't have one |
33 | 34 | $record = $dbr->selectRow( |
— | — | @@ -120,6 +121,30 @@ |
121 | 122 | |
122 | 123 | ApiArticleFeedbackv5Utils::incrementFilterCounts( $pageId, $counts['increment'] ); |
123 | 124 | ApiArticleFeedbackv5Utils::decrementFilterCounts( $pageId, $counts['decrement'] ); |
| 125 | + |
| 126 | + // This gets a potentially stale copy from the read |
| 127 | + // database assumes it's valid, in the interest |
| 128 | + // of staying off of the write database. |
| 129 | + // Better stale data than wail on the master, IMO, |
| 130 | + // but I'm open to suggestion on that one. |
| 131 | + |
| 132 | + // Update helpful/unhelpful count after submission |
| 133 | + if( $params['flagtype'] == 'helpful' || $params['flagtype'] == 'unhelpful' ) { |
| 134 | + $record = $dbr->selectRow( |
| 135 | + 'aft_article_feedback', |
| 136 | + array( 'af_helpful_count', 'af_unhelpful_count' ), |
| 137 | + array( 'af_id' => $params['feedbackid'] ), |
| 138 | + __METHOD__ |
| 139 | + ); |
| 140 | + |
| 141 | + $helpful = $record->af_helpful_count; |
| 142 | + $unhelpful = $record->af_unhelpful_count; |
| 143 | + |
| 144 | + $helpful = wfMessage( 'articlefeedbackv5-form-helpful-votes', |
| 145 | + ( $helpful + $unhelpful ), |
| 146 | + $helpful, $unhelpful |
| 147 | + )->escaped(); |
| 148 | + } |
124 | 149 | } |
125 | 150 | |
126 | 151 | if ( $error ) { |
— | — | @@ -130,13 +155,19 @@ |
131 | 156 | $reason = null; |
132 | 157 | } |
133 | 158 | |
| 159 | + $results = array( |
| 160 | + 'result' => $result, |
| 161 | + 'reason' => $reason, |
| 162 | + ); |
| 163 | + |
| 164 | + if( $helpful ) { |
| 165 | + $results['helpful'] = $helpful; |
| 166 | + } |
| 167 | + |
134 | 168 | $this->getResult()->addValue( |
135 | 169 | null, |
136 | 170 | $this->getModuleName(), |
137 | | - array( |
138 | | - 'result' => $result, |
139 | | - 'reason' => $reason, |
140 | | - ) |
| 171 | + $results |
141 | 172 | ); |
142 | 173 | } |
143 | 174 | |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php |
— | — | @@ -344,7 +344,8 @@ |
345 | 345 | ), wfMessage( 'articlefeedbackv5-form-helpful-no-label', $record[0]->af_unhelpful_count )->text() ); |
346 | 346 | } |
347 | 347 | $footer_links .= Html::element( 'span', array( |
348 | | - 'class' => 'articleFeedbackv5-helpful-votes' |
| 348 | + 'class' => 'articleFeedbackv5-helpful-votes', |
| 349 | + 'id' => "articleFeedbackv5-helpful-votes-$id" |
349 | 350 | ), wfMessage( 'articlefeedbackv5-form-helpful-votes', ( $record[0]->af_helpful_count + $record[0]->af_unhelpful_count ), $record[0]->af_helpful_count, $record[0]->af_unhelpful_count ) ); |
350 | 351 | if( $can_flag ) { |
351 | 352 | $footer_links .= Html::element( 'a', array( |