| <?php |
| |
| require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection_dashboard_rw.class.php"; |
| |
| function logNotZero($value) { |
| if( $value == 0 ) { |
| return $value; |
| } else { |
| return log($value); |
| } |
| } |
| |
| function logAbsZero($value) { |
| if( $value == 0 ) { |
| return $value; |
| } else { |
| if( $value < 0 ) { |
| return -1 * log(abs($value)); |
| } else { |
| return log($value); |
| } |
| } |
| } |
| |
| function inverseNotZero($value) { |
| if($value == 0) { |
| return $value; |
| } else { |
| return 1.0 / $value; |
| } |
| } |
| |
| class Live { |
| var $db_connection; |
| var $db_handle; |
| |
| function Live(){ |
| // Initialize the DB connection |
| $this->db_connection = new DBConnectionDashboard(); |
| $this->db_handle = $this->db_connection->connect(); |
| } |
| |
| function computeData($table){ |
| $i = 0; |
| $livenesss = Array(); |
| $today = date('Y-m-d'); |
| |
| $query = "SELECT * FROM ".$table." WHERE stats_date = \"".$today."\""; |
| $result = mysql_query($query,$this->db_handle); |
| while($row = mysql_fetch_assoc($result)){ |
| $project[$i] = $row['project']; |
| $delta_bugs_7 = 1 * logNotZero($row['bugs_7_delta']); |
| $percent_bugs_7 = 1 * logAbsZero($row['bugs_7_percentage']); |
| $percent_bugs_30 = 2 * logAbsZero($row['bugs_30_percentage']); |
| $percent_bugs_180 = 1 * logAbsZero($row['bugs_180_percentage']); |
| $posts_news_7 = 2 * logAbsZero($row['news_7_number_posts']); |
| $answers_news_7 = 2 * inverseNotZero($row['news_7_answer_average_time']); |
| $posts_news_30 = 3 * logAbsZero($row['news_30_number_posts']); |
| $answers_news_30 = 3 * inverseNotZero($row['news_30_answer_average_time']); |
| |
| $total = $delta_bugs_7 + |
| $percent_bugs_7 + |
| $percent_bugs_30 + |
| $percent_bugs_180 + |
| $posts_news_7 + |
| $answers_news_7 + |
| $posts_news_30 + |
| $answers_news_30; |
| |
| if( ($total == 0) && ($percent_bugs_180 == 0) ) { |
| $total = -1000; |
| } |
| |
| $liveness[$i] = $total; |
| $i++; |
| } |
| echo "<html>\n<body>\n"; |
| while(--$i >= 0){ |
| echo "<b>Processing project:</b> ".$project[$i]." <b>Liveness:</b> ".$liveness[$i]."<br>\n"; |
| $query = "UPDATE ".$table." SET liveness = ".$liveness[$i]." WHERE project = \"".$project[$i]."\" AND stats_date = \"".$today."\""; |
| mysql_query($query,$this->db_handle) or die("Could not update stats: ".mysql_error()); |
| } |
| echo "\n</body>\n</html>\n"; |
| } |
| |
| function destroyLive(){ |
| $this->db_handle = null; |
| $this->db_connection = null; |
| } |
| } |
| |
| ?> |