Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Month.php « ArchiveProcessing « modules - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd7e5b91141158d5e8895686e671e0adfd707502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php


class Piwik_ArchiveProcessing_Month extends Piwik_ArchiveProcessing
{
	function __construct()
	{
	}
	
	protected function getRecordNumericSum( $aNames )
	{
		if(!is_array($aNames))
		{
			$aNames = array($aNames);
		}
		
		// fetch the numeric values and sum them
		$results = array();
		foreach($this->archives as $archive)
		{
			$archive->preFetch($aNames);
			
			foreach($aNames as $name)
			{
				if(!isset($results[$name]))
				{
					$results[$name] = 0;
				}
				$valueToSum = $archive->getNumeric($name);
				
				if($valueToSum !== false)
				{
					$results[$name] += $valueToSum;					
				}
			}
		}
		
		// build the Record Numeric objects
		$records = array();
		foreach($results as $name => $value)
		{
			$records[$name] = new Piwik_Archive_Processing_Record_Numeric(
													$name, 
													$value
												);
		}
		
		// if asked for only one field to sum
		if(count($records) == 1)
		{
			return $records[$name];
		}
		
		// returns the array of records once summed
		return $records;
	}
	
	protected function getRecordDataTableSum( $name )
	{
		$table = new Piwik_DataTable;
		foreach($this->archives as $archive)
		{
			$datatableToSum = $archive->getDataTable($name);
			$table->addDataTable($datatableToSum);
		}
		return $table;
	}
	
	protected function compute()
	{		
		$this->archives = $this->archivesSubperiods;
		
		echo $this->getRecordNumericSum('nb_visits');
		$records = $this->getRecordNumericSum(array('nb_uniq_visitors', 'nb_actions'));
		foreach($records as $rec) echo $rec."<br>";
		
		echo $this->getRecordDataTableSum('UserSettings_browserType');
//		Piwik_PostEvent('ArchiveProcessing_Month.compute', $this);

//		$nbVisits = new Piwik_ArchiveProcessing_Record('nb_visits',
//						new Piwik_ArchiveProcessing_Record_NumericSum)
	}
	
}
?>