r91403 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91402‎ | r91403 | r91404 >
Date:12:15, 4 July 2011
Author:yuvipanda
Status:deferred
Tags:
Comment:
Simplified database code
Modified paths:
  • /trunk/extensions/GPoC/models/Rating.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GPoC/models/Rating.php
@@ -45,8 +45,6 @@
4646 return;
4747 }
4848 $dbw = wfGetDB( DB_MASTER );
49 - // Rating has just been detected.
50 - // So we can ignore $old_importance and $old_quality
5149 $importance_column = Statistics::getImportanceColumn( $this->importance );
5250 $dbw->insert(
5351 'project_stats',
@@ -68,37 +66,30 @@
6967 __METHOD__
7068 );
7169
72 - //FIXME: Needs cleaner logic for four combinations of what can change
73 - //Just Importance, Just Quality, Neither and Both
74 - //Currently, code fails for 'both'.
75 - if(! $is_new_rating && ! empty( $this->old_importance ) ) {
76 - $old_importance_column = Statistics::getImportanceColumn( $this->old_importance );
77 - $dbw->update(
78 - 'project_stats',
79 - array( "$old_importance_column = $old_importance_column - 1" ),
80 - array(
81 - "ps_project" => $this->project,
82 - "ps_quality" => $this->quality
83 - ),
84 - __METHOD__
85 - );
86 - }
87 - if(! $is_new_rating && ! empty( $this->old_quality ) ) {
88 - if(! isset($old_importance_column) ) {
89 - $old_importance_column = $importance_column;
 70+ if(! $is_new_rating ) {
 71+ // Is not a new rating, and atleast one of quality or importance has changed
 72+ if(! empty( $this->old_quality ) ) {
 73+ $q_value = $this->old_quality;
 74+ } else {
 75+ $q_value = $this->quality;
9076 }
 77+ if(! empty( $this->old_importance) ) {
 78+ $i_column = Statistics::getImportanceColumn( $this->old_importance );
 79+ } else {
 80+ $i_column = Statistics::getImportanceColumn( $this->importance );
 81+ }
9182 $dbw->update(
9283 'project_stats',
93 - array( "$old_importance_column = $old_importance_column - 1" ),
 84+ array( "$i_column = $i_column - 1" ),
9485 array(
9586 "ps_project" => $this->project,
96 - "ps_quality" => $this->old_quality
 87+ "ps_quality" => $q_value
9788 ),
9889 __METHOD__
9990 );
100 -
10191 }
10292 }
 93+
10394 public function saveAll() {
10495 $data_array = array(
10596 'r_project' => $this->project,

Status & tagging log