Skip to content
Extraits de code Groupes Projets
Valider 0cb0472b rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Refs #4200 started documenting LogAggregator and documented Plugin/API.

parent fdb2cbaa
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -21,8 +21,14 @@ use Piwik\Site; ...@@ -21,8 +21,14 @@ use Piwik\Site;
use Piwik\Tracker\GoalManager; use Piwik\Tracker\GoalManager;
/** /**
* This class queries the Visitor logs tables (visits, actions, conversions, ecommerce) * Contains methods that aggregates log data (visits, actions, conversions, ecommerce).
* and returns aggregate data. *
* Plugin [Archiver](#) descendants can use the methods in this class to aggregate data
* in the log tables without creating their own SQL queries.
*
* ### Examples
*
* ** TODO **
*/ */
class LogAggregator class LogAggregator
{ {
...@@ -126,22 +132,36 @@ class LogAggregator ...@@ -126,22 +132,36 @@ class LogAggregator
} }
/** /**
* Query visits logs by dimension, and return the aggregate data. * Queries visit logs by dimension and returns the aggregate data.
* *
* @param array|string $dimensions Can be a string, eg. "referrer_name", will be aliased as 'label' in the returned rows * @param array|string $dimensions SELECT fields (or just one field) that will be grouped by,
* Can also be an array of strings, when the dimension spans multiple fields, * eg, `'referrer_name'` or `array('referrer_name', 'referrer_keyword')`.
* eg. array("referrer_name", "referrer_keyword") * The metrics retrieved from the query will be specific to combinations
* @param bool|string $where Additional condition for WHERE clause * of these fields. So if `array('referrer_name', 'referrer_keyword')`
* @param array $additionalSelects Additional SELECT clause * is supplied, the query will select the visits for each referrer/keyword
* @param bool|array $metrics Set this if you want to limit the columns that are returned. * combination.
* The possible values in the array are Metrics::INDEX_*. * @param bool|string $where Additional condition for the WHERE clause. Can be used to filter
* the set of visits that are looked at.
* @param array $additionalSelects Additional SELECT fields that are not included in the group by
* clause. These can be aggregate expressions, eg, `SUM(somecol)`.
* @param bool|array $metrics The set of metrics to return. If false, the query will select all of them.
* The following values can be used:
* - Metrics::INDEX_NB_UNIQ_VISITORS
* - Metrics::INDEX_NB_VISITS
* - Metrics::INDEX_NB_ACTIONS
* - Metrics::INDEX_MAX_ACTIONS
* - Metrics::INDEX_SUM_VISIT_LENGTH
* - Metrics::INDEX_BOUNCE_COUNT
* - Metrics::INDEX_NB_VISITS_CONVERTED
* @param bool|\Piwik\RankingQuery $rankingQuery * @param bool|\Piwik\RankingQuery $rankingQuery
* A pre-configured ranking query instance that is used to limit the result. * A pre-configured ranking query instance that will be used to limit the result.
* If set, the return value is the array returned by RankingQuery::execute(). * If set, the return value is the array returned by [RankingQuery::execute()](#).
* * @return mixed A Zend_Db_Statement if `$rankingQuery` isn't supplied, otherwise the result of
* @return mixed * [RankingQuery::execute()](#).
* @api
*/ */
public function queryVisitsByDimension(array $dimensions = array(), $where = false, array $additionalSelects = array(), $metrics = false, $rankingQuery = false) public function queryVisitsByDimension(array $dimensions = array(), $where = false, array $additionalSelects = array(),
$metrics = false, $rankingQuery = false)
{ {
$tableName = self::LOG_VISIT_TABLE; $tableName = self::LOG_VISIT_TABLE;
$availableMetrics = $this->getVisitsMetricFields(); $availableMetrics = $this->getVisitsMetricFields();
...@@ -314,7 +334,7 @@ class LogAggregator ...@@ -314,7 +334,7 @@ class LogAggregator
} }
/** /**
* Returns the ecommerce items * Queries all ecommerce items.
* *
* @param string $field * @param string $field
* @return string * @return string
...@@ -342,8 +362,7 @@ class LogAggregator ...@@ -342,8 +362,7 @@ class LogAggregator
// $query = $this->query($select, $from, $where, $groupBy, $orderBy); // $query = $this->query($select, $from, $where, $groupBy, $orderBy);
$bind = $this->getBindDatetimeSite(); $bind = $this->getBindDatetimeSite();
$query = $this->getDb()->query($query, $bind); return $this->getDb()->query($query, $bind);
return $query;
} }
/** /**
......
...@@ -13,7 +13,27 @@ namespace Piwik\Plugin; ...@@ -13,7 +13,27 @@ namespace Piwik\Plugin;
use Piwik\Singleton; use Piwik\Singleton;
/**
* The base class of all API singletons.
*
* Plugins that want to expose functionality through an API should create a class
* that derives from this one. Every public method in that class will be callable
* through Piwik's API.
*
* ### Example
*
* class MyAPI extends API
* {
* public function myMethod($idSite, $period, $date, $segment = false)
* {
* $dataTable = // ... get some data ...
* return $dataTable;
* }
* }
*
* @api
*/
abstract class API extends Singleton abstract class API extends Singleton
{ {
} }
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter