Skip to content
Extraits de code Groupes Projets
Valider bbafc1c0 rédigé par mattpiwik's avatar mattpiwik
Parcourir les fichiers

Refs #2670

 * Fixing few bugs found by integration tests and hopefully fixing build!

git-svn-id: http://dev.piwik.org/svn/trunk@5298 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 00815a3d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 35 ajouts et 20 suppressions
...@@ -346,14 +346,9 @@ class Piwik_API_API ...@@ -346,14 +346,9 @@ class Piwik_API_API
public function getMetadata($idSite, $apiModule, $apiAction, $apiParameters = array(), $language = false, $period = false, $date = false) public function getMetadata($idSite, $apiModule, $apiAction, $apiParameters = array(), $language = false, $period = false, $date = false)
{ {
Piwik_Translate::getInstance()->reloadLanguage($language); Piwik_Translate::getInstance()->reloadLanguage($language);
static $reportsMetadata = array(); $reportsMetadata = $this->getReportMetadata($idSite, $period, $date);
$cacheKey = $idSite.$language;
if(!isset($reportsMetadata[$cacheKey]))
{
$reportsMetadata[$cacheKey] = $this->getReportMetadata($idSite, $period, $date);
}
foreach($reportsMetadata[$cacheKey] as $report) foreach($reportsMetadata as $report)
{ {
// See ArchiveProcessing/Period.php - unique visitors are not processed for period != day // See ArchiveProcessing/Period.php - unique visitors are not processed for period != day
if($period != 'day' if($period != 'day'
......
...@@ -281,6 +281,10 @@ class Piwik_ImageGraph_API ...@@ -281,6 +281,10 @@ class Piwik_ImageGraph_API
//Otherwise we have rows //Otherwise we have rows
else if(!empty($metadata[0]['dimension'])) else if(!empty($metadata[0]['dimension']))
{ {
if(!($report["reportData"] instanceof Piwik_DataTable))
{
throw new Exception("The graph cannot be drawn with the request 'date' and 'period' parameters.");
}
foreach($report["reportData"]->getRows() as $rowId => $row) foreach($report["reportData"]->getRows() as $rowId => $row)
{ {
$row = $row->getColumns(); $row = $row->getColumns();
......
...@@ -62,9 +62,18 @@ class Piwik_ImageGraph extends Piwik_Plugin ...@@ -62,9 +62,18 @@ class Piwik_ImageGraph extends Piwik_Plugin
$dateLastN = $info['date']; $dateLastN = $info['date'];
// If the date is not already a range, then we process the range to plot on Graph // If the date is not already a range, then we process the range to plot on Graph
if(!Piwik_Archive::isMultiplePeriod($info['date'], $info['period'])) if($info['period'] != 'range')
{ {
$dateLastN = Piwik_Controller::getDateRangeRelativeToEndDate($info['period'], $lastN, $info['date'], new Piwik_Site($idSite)); if(!Piwik_Archive::isMultiplePeriod($info['date'], $info['period']))
{
$dateLastN = Piwik_Controller::getDateRangeRelativeToEndDate($info['period'], $lastN, $info['date'], new Piwik_Site($idSite));
}
// Period is not range, but date is already date1,date2 format
// so we draw the graph over the requested range
else
{
$info['period'] = 'range';
}
} }
$token_auth = Piwik_Common::getRequestVar('token_auth', false); $token_auth = Piwik_Common::getRequestVar('token_auth', false);
...@@ -93,7 +102,12 @@ class Piwik_ImageGraph extends Piwik_Plugin ...@@ -93,7 +102,12 @@ class Piwik_ImageGraph extends Piwik_Plugin
if(empty($report['dimension'])) if(empty($report['dimension']))
{ {
$parameters['graphType'] = 'evolution'; $parameters['graphType'] = 'evolution';
$parameters['date'] = $dateLastN;
// If period == range, then date is already a date range
if($info['period'] != 'range')
{
$parameters['date'] = $dateLastN;
}
} }
$report['imageGraphUrl'] = $urlPrefix . Piwik_Url::getQueryStringFromParameters($parameters); $report['imageGraphUrl'] = $urlPrefix . Piwik_Url::getQueryStringFromParameters($parameters);
......
...@@ -460,6 +460,8 @@ abstract class Test_Integration extends Test_Database ...@@ -460,6 +460,8 @@ abstract class Test_Integration extends Test_Database
$response = $this->removeXmlElement($response, 'sum_daily_nb_uniq_visitors'); $response = $this->removeXmlElement($response, 'sum_daily_nb_uniq_visitors');
$expected = $this->removeXmlElement($expected, 'nb_visits_converted'); $expected = $this->removeXmlElement($expected, 'nb_visits_converted');
$response = $this->removeXmlElement($response, 'nb_visits_converted'); $response = $this->removeXmlElement($response, 'nb_visits_converted');
$expected = $this->removeXmlElement($expected, 'imageGraphUrl');
$response = $this->removeXmlElement($response, 'imageGraphUrl');
$removeEndOfLines =true; $removeEndOfLines =true;
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</metricsDocumentation> </metricsDocumentation>
<documentation>This report shows a hierarchical list of outlink URLs that were clicked by your visitors. An outlink is a link that leads the visitor away from your website (to another domain).&lt;br /&gt;Use the plus and minus icons on the left to navigate.</documentation> <documentation>This report shows a hierarchical list of outlink URLs that were clicked by your visitors. An outlink is a link that leads the visitor away from your website (to another domain).&lt;br /&gt;Use the plus and minus icons on the left to navigate.</documentation>
<imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=Actions&amp;apiAction=getOutlinks&amp;graphType=verticalBar&amp;period=day&amp;date=2011-04-05</imageGraphUrl> <imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=Actions&amp;apiAction=getOutlinks&amp;graphType=verticalBar&amp;period=range&amp;date=2010-01-03,2010-01-09</imageGraphUrl>
<uniqueId>Actions_getOutlinks</uniqueId> <uniqueId>Actions_getOutlinks</uniqueId>
</metadata> </metadata>
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</metricsDocumentation> </metricsDocumentation>
<documentation>This report contains information about the titles of the pages that have been visited. &lt;br /&gt; The page title is the HTML &lt;title&gt; Tag that most browsers show in their window title.</documentation> <documentation>This report contains information about the titles of the pages that have been visited. &lt;br /&gt; The page title is the HTML &lt;title&gt; Tag that most browsers show in their window title.</documentation>
<imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=Actions&amp;apiAction=getPageTitles&amp;graphType=verticalBar&amp;period=day&amp;date=2011-04-05</imageGraphUrl> <imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=Actions&amp;apiAction=getPageTitles&amp;graphType=verticalBar&amp;period=range&amp;date=2010-01-03,2010-01-09</imageGraphUrl>
<uniqueId>Actions_getPageTitles</uniqueId> <uniqueId>Actions_getPageTitles</uniqueId>
</metadata> </metadata>
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</metricsDocumentation> </metricsDocumentation>
<documentation>This report contains information about the page URLs that have been visited. &lt;br /&gt; The table is organized hierarchically, the URLs are displayed as a folder structure.&lt;br /&gt;Use the plus and minus icons on the left to navigate.</documentation> <documentation>This report contains information about the page URLs that have been visited. &lt;br /&gt; The table is organized hierarchically, the URLs are displayed as a folder structure.&lt;br /&gt;Use the plus and minus icons on the left to navigate.</documentation>
<imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=Actions&amp;apiAction=getPageUrls&amp;graphType=verticalBar&amp;period=day&amp;date=2011-04-05</imageGraphUrl> <imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=Actions&amp;apiAction=getPageUrls&amp;graphType=verticalBar&amp;period=range&amp;date=2010-01-03,2010-01-09</imageGraphUrl>
<uniqueId>Actions_getPageUrls</uniqueId> <uniqueId>Actions_getPageUrls</uniqueId>
</metadata> </metadata>
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<revenue_per_visit>Revenue per Visit</revenue_per_visit> <revenue_per_visit>Revenue per Visit</revenue_per_visit>
</processedMetricsGoal> </processedMetricsGoal>
<imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=Referers&amp;apiAction=getWebsites&amp;graphType=verticalBar&amp;period=day&amp;date=2011-04-05</imageGraphUrl> <imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=Referers&amp;apiAction=getWebsites&amp;graphType=verticalBar&amp;period=range&amp;date=2010-01-03,2010-01-09</imageGraphUrl>
<uniqueId>Referers_getWebsites</uniqueId> <uniqueId>Referers_getWebsites</uniqueId>
</metadata> </metadata>
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<exit_rate>The percentage of visits that left the website after viewing this page.</exit_rate> <exit_rate>The percentage of visits that left the website after viewing this page.</exit_rate>
</metricsDocumentation> </metricsDocumentation>
<imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=VisitFrequency&amp;apiAction=get&amp;graphType=evolution&amp;period=day&amp;date=2011-03-07,2011-04-05</imageGraphUrl> <imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=VisitFrequency&amp;apiAction=get&amp;graphType=evolution&amp;period=range&amp;date=2010-01-03,2010-01-09</imageGraphUrl>
<uniqueId>VisitFrequency_get</uniqueId> <uniqueId>VisitFrequency_get</uniqueId>
</metadata> </metadata>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<exit_rate>The percentage of visits that left the website after viewing this page.</exit_rate> <exit_rate>The percentage of visits that left the website after viewing this page.</exit_rate>
</metricsDocumentation> </metricsDocumentation>
<imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=VisitsSummary&amp;apiAction=get&amp;graphType=evolution&amp;period=day&amp;date=2011-03-07,2011-04-05</imageGraphUrl> <imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=VisitsSummary&amp;apiAction=get&amp;graphType=evolution&amp;period=range&amp;date=2010-01-03,2010-01-09</imageGraphUrl>
<uniqueId>VisitsSummary_get</uniqueId> <uniqueId>VisitsSummary_get</uniqueId>
</metadata> </metadata>
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<revenue_per_visit>Revenue per Visit</revenue_per_visit> <revenue_per_visit>Revenue per Visit</revenue_per_visit>
</processedMetricsGoal> </processedMetricsGoal>
<imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=UserCountry&amp;apiAction=getCountry&amp;graphType=verticalBar&amp;period=day&amp;date=2011-04-05</imageGraphUrl> <imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=UserCountry&amp;apiAction=getCountry&amp;graphType=verticalBar&amp;period=day&amp;date=2009-01-04</imageGraphUrl>
<uniqueId>UserCountry_getCountry</uniqueId> <uniqueId>UserCountry_getCountry</uniqueId>
</row> </row>
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<revenue_per_visit>Revenue per Visit</revenue_per_visit> <revenue_per_visit>Revenue per Visit</revenue_per_visit>
</processedMetricsGoal> </processedMetricsGoal>
<imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=UserCountry&amp;apiAction=getCountry&amp;graphType=verticalBar&amp;period=day&amp;date=2011-04-05</imageGraphUrl> <imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=UserCountry&amp;apiAction=getCountry&amp;graphType=verticalBar&amp;period=day&amp;date=2009-01-04</imageGraphUrl>
<uniqueId>UserCountry_getCountry</uniqueId> <uniqueId>UserCountry_getCountry</uniqueId>
</metadata> </metadata>
......
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<result> <result>
<website>Piwik test</website> <website>Piwik test</website>
<prettyDate>8 Oct 11 - 14 Oct 11</prettyDate>
<metadata> <metadata>
<category>Visitors</category> <category>Visitors</category>
<name>Country</name> <name>Country</name>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<revenue_per_visit>Revenue per Visit</revenue_per_visit> <revenue_per_visit>Revenue per Visit</revenue_per_visit>
</processedMetricsGoal> </processedMetricsGoal>
<imageGraphUrl>index.php?module=API&amp;method=ImageGraph.get&amp;idSite=1&amp;apiModule=UserCountry&amp;apiAction=getCountry&amp;graphType=verticalBar&amp;period=day&amp;date=2011-04-05</imageGraphUrl>
<uniqueId>UserCountry_getCountry</uniqueId> <uniqueId>UserCountry_getCountry</uniqueId>
</metadata> </metadata>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter