Code Duplication    Length = 41-41 lines in 2 locations

require/class.Spotter.php 2 locations

@@ 7056-7096 (lines=41) @@
7053
	* @return Array the date list
7054
	*
7055
	*/
7056
	public function countAllDatesLast7Days()
7057
	{
7058
		global $globalTimezone, $globalDBdriver;
7059
		if ($globalTimezone != '') {
7060
			date_default_timezone_set($globalTimezone);
7061
			$datetime = new DateTime();
7062
			$offset = $datetime->format('P');
7063
		} else $offset = '+00:00';
7064
		
7065
		if ($globalDBdriver == 'mysql') {
7066
			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7067
								FROM spotter_output 
7068
								WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)
7069
								GROUP BY date_name 
7070
								ORDER BY spotter_output.date ASC";
7071
			$query_data = array(':offset' => $offset);
7072
		} elseif ($globalDBdriver == 'pgsql') {
7073
			$query  = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7074
								FROM spotter_output 
7075
								WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '7 DAYS'
7076
								GROUP BY date_name 
7077
								ORDER BY date_name ASC";
7078
			$query_data = array(':offset' => $offset);
7079
    		}
7080
		
7081
		$sth = $this->db->prepare($query);
7082
		$sth->execute($query_data);
7083
      
7084
		$date_array = array();
7085
		$temp_array = array();
7086
        
7087
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7088
		{
7089
			$temp_array['date_name'] = $row['date_name'];
7090
			$temp_array['date_count'] = $row['date_count'];
7091
          
7092
			$date_array[] = $temp_array;
7093
		}
7094
7095
		return $date_array;
7096
	}
7097
7098
	/**
7099
	* Counts all dates during the last month
@@ 7104-7144 (lines=41) @@
7101
	* @return Array the date list
7102
	*
7103
	*/
7104
	public function countAllDatesLastMonth()
7105
	{
7106
		global $globalTimezone, $globalDBdriver;
7107
		if ($globalTimezone != '') {
7108
			date_default_timezone_set($globalTimezone);
7109
			$datetime = new DateTime();
7110
			$offset = $datetime->format('P');
7111
		} else $offset = '+00:00';
7112
		
7113
		if ($globalDBdriver == 'mysql') {
7114
			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7115
								FROM spotter_output 
7116
								WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)
7117
								GROUP BY date_name 
7118
								ORDER BY spotter_output.date ASC";
7119
			$query_data = array(':offset' => $offset);
7120
		} elseif ($globalDBdriver == 'pgsql') {
7121
			$query  = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7122
								FROM spotter_output 
7123
								WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'
7124
								GROUP BY date_name 
7125
								ORDER BY date_name ASC";
7126
			$query_data = array(':offset' => $offset);
7127
    		}
7128
		
7129
		$sth = $this->db->prepare($query);
7130
		$sth->execute($query_data);
7131
      
7132
		$date_array = array();
7133
		$temp_array = array();
7134
        
7135
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7136
		{
7137
			$temp_array['date_name'] = $row['date_name'];
7138
			$temp_array['date_count'] = $row['date_count'];
7139
          
7140
			$date_array[] = $temp_array;
7141
		}
7142
7143
		return $date_array;
7144
	}
7145
	
7146
	/**
7147
	* Counts all month