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

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenaka Moorthi <benaka.moorthi@gmail.com>2013-09-11 19:49:36 +0400
committerBenaka Moorthi <benaka.moorthi@gmail.com>2013-09-12 02:41:23 +0400
commit94eff35d47c5be86d88b51e933bec3fb8ee450cd (patch)
tree7f8b46291ce5a5cbe935d9e72e807b48a62971af /plugins/Live
parent8f423e7552d09e3457ef27185bccd219717d1fef (diff)
Refs #3089, tweaks and fixes to visitor profile interface and make sure adjacent visitor retrieval works w/ segments.
Diffstat (limited to 'plugins/Live')
-rw-r--r--plugins/Live/API.php41
-rw-r--r--plugins/Live/javascripts/visitorProfile.js6
-rw-r--r--plugins/Live/stylesheets/visitor_profile.less17
-rw-r--r--plugins/Live/templates/getSingleVisitSummary.twig4
-rw-r--r--plugins/Live/templates/getVisitorProfilePopup.twig4
5 files changed, 38 insertions, 34 deletions
diff --git a/plugins/Live/API.php b/plugins/Live/API.php
index e81997641e..0fa645f0ff 100644
--- a/plugins/Live/API.php
+++ b/plugins/Live/API.php
@@ -181,12 +181,9 @@ class API
$idVisitor = $this->getMostRecentVisitorId($idSite, $segment);
}
- if ($segment !== false) {
- $segment .= ';';
- }
- $segment .= 'visitorId==' . $idVisitor;
+ $newSegment = ($segment === false ? '' : $segment . ';') . 'visitorId==' . $idVisitor;
- $visits = $this->getLastVisitsDetails($idSite, $period = false, $date = false, $segment,
+ $visits = $this->getLastVisitsDetails($idSite, $period = false, $date = false, $newSegment,
$filter_limit = self::VISITOR_PROFILE_MAX_VISITS_TO_AGGREGATE,
$filter_offset = false, $visitorId = false, $minTimestamp = false);
if ($visits->getRowsCount() == 0) {
@@ -311,8 +308,8 @@ class API
// TODO: make sure order of visitor ids is not changed if a returning visitor visits while the user is
// looking at the popup.
$latestVisitTime = reset($rows)->getColumn('lastActionDateTime');
- $result['nextVisitorId'] = $this->getAdjacentVisitorId($idSite, $idVisitor, $latestVisitTime, $getNext = true);
- $result['prevVisitorId'] = $this->getAdjacentVisitorId($idSite, $idVisitor, $latestVisitTime, $getNext = false);
+ $result['nextVisitorId'] = $this->getAdjacentVisitorId($idSite, $idVisitor, $latestVisitTime, $segment, $getNext = true);
+ $result['prevVisitorId'] = $this->getAdjacentVisitorId($idSite, $idVisitor, $latestVisitTime, $segment, $getNext = false);
Piwik_PostEvent(Live::GET_EXTRA_VISITOR_DETAILS_EVENT, array(&$result));
@@ -348,30 +345,40 @@ class API
* @param int $idSite The ID of the site whose visits should be looked at.
* @param string $idVisitor The ID of the visitor to get an adjacent visitor for.
* @param string $visitLastActionTime The last action time of the latest visit for $idVisitor.
+ * @param string $segment
* @param bool $getNext Whether to retrieve the next visitor or the previous visitor. The next
* visitor will be the visitor that appears chronologically later in the
* log_visit table. The previous visitor will be the visitor that appears
* earlier.
* @return string The hex visitor ID.
*/
- private function getAdjacentVisitorId($idSite, $idVisitor, $visitLastActionTime, $getNext)
+ private function getAdjacentVisitorId($idSite, $idVisitor, $visitLastActionTime, $segment, $getNext)
{
if ($getNext) {
- $visitLastActionTimeCondition = "visit_last_action_time <= ?";
+ $visitLastActionTimeCondition = "sub.visit_last_action_time <= ?";
$orderByDir = "DESC";
} else {
- $visitLastActionTimeCondition = "visit_last_action_time >= ?";
+ $visitLastActionTimeCondition = "sub.visit_last_action_time >= ?";
$orderByDir = "ASC";
}
- $sql = "SELECT idvisitor, MAX(visit_last_action_time)
- FROM " . Common::prefixTable('log_visit') . "
- WHERE idsite = ? AND idvisitor <> UNHEX(?) AND $visitLastActionTimeCondition
- GROUP BY idvisitor
- ORDER BY MAX(visit_last_action_time) $orderByDir
+ $select = "log_visit.idvisitor, MAX(log_visit.visit_last_action_time) as visit_last_action_time";
+ $from = "log_visit";
+ $where = "log_visit.idsite = ? AND log_visit.idvisitor <> UNHEX(?)";
+ $whereBind = array($idSite, $idVisitor);
+ $orderBy = "MAX(log_visit.visit_last_action_time) $orderByDir";
+ $groupBy = "log_visit.idvisitor";
+
+ $segment = new Segment($segment, $idSite);
+ $queryInfo = $segment->getSelectQuery($select, $from, $where, $whereBind, $orderBy, $groupBy);
+
+ $sql = "SELECT sub.idvisitor, sub.visit_last_action_time
+ FROM ({$queryInfo['sql']}) as sub
+ WHERE $visitLastActionTimeCondition
LIMIT 1";
+ $bind = array_merge($queryInfo['bind'], array($visitLastActionTime));
- $idVisitor = Db::fetchOne($sql, array($idSite, $idVisitor, $visitLastActionTime));
+ $idVisitor = Db::fetchOne($sql, $bind);
if (!empty($idVisitor)) {
$idVisitor = bin2hex($idVisitor);
}
@@ -955,4 +962,4 @@ class API
$visitorDetailsArray['goalConversions'] = count($goalDetails);
return $visitorDetailsArray;
}
-}
+} \ No newline at end of file
diff --git a/plugins/Live/javascripts/visitorProfile.js b/plugins/Live/javascripts/visitorProfile.js
index 12f93c35e5..5b85211b0c 100644
--- a/plugins/Live/javascripts/visitorProfile.js
+++ b/plugins/Live/javascripts/visitorProfile.js
@@ -106,21 +106,19 @@
}
});
- var mapShown = false;
$element.on('click', '.visitor-profile-show-map', function (e) {
e.preventDefault();
var $map = $('.visitor-profile-map', $element);
if ($map.is(':hidden')) {
- if (!mapShown) {
+ if ($map.height() < 1) {
$map.resize();
- mapShown = true;
}
$map.slideDown('slow');
var newLabel = 'Live_HideMap_js';
- piwikHelper.lazyScrollTo($('.visitor-profile-location', $element)[0], 400, true);
+ piwikHelper.lazyScrollTo($('.visitor-profile-location', $element)[0], 400);
} else {
$map.slideUp('slow');
var newLabel = 'Live_ShowMap_js';
diff --git a/plugins/Live/stylesheets/visitor_profile.less b/plugins/Live/stylesheets/visitor_profile.less
index 6200eace0a..cf1db666da 100644
--- a/plugins/Live/stylesheets/visitor_profile.less
+++ b/plugins/Live/stylesheets/visitor_profile.less
@@ -27,6 +27,7 @@
border-radius:5px;
background:url(../images/visitor_profile_background.jpg) repeat;
box-shadow:5px 5px 5px rgba(0,0,0,0.22);
+ text-align:left;
h1 {
font-size:18px;
@@ -59,7 +60,7 @@
.visitor-profile-summary,.visitor-profile-important-visits,.visitor-profile-avatar,.visitor-profile-visits-container {
span, strong {
- display:inline-block;
+ display:inline;
font-size:14px;
color:#5e5e5c;
line-height:19px;
@@ -203,8 +204,8 @@
display:inline-block;
}
-.visitor-profile-latest-visit-column:first-child {
- margin-right:9px;
+.visitor-profile-latest-visit-column:last-child {
+ margin-left:9px;
}
.visitor-profile-avatar ul {
@@ -502,8 +503,9 @@ div.visitor-profile-navigation {
margin-right:2px;
}
-.visitor-profile-next-visitor {
+a.visitor-profile-next-visitor,a.visitor-profile-prev-visitor {
display:none;
+ color:#7e7363;
}
.visitor-profile-avatar:hover {
@@ -521,13 +523,8 @@ div.visitor-profile-navigation {
.visitor-profile-latest-visit-loc {
display:inline-block;
position:absolute;
- right:0;
+ right:4px;
top:-24px;
-
- > span {
- font-style:italic;
- font-size:13px;
- }
}
.widget .visitor-profile {
diff --git a/plugins/Live/templates/getSingleVisitSummary.twig b/plugins/Live/templates/getSingleVisitSummary.twig
index e3a68cf470..9ab2815501 100644
--- a/plugins/Live/templates/getSingleVisitSummary.twig
+++ b/plugins/Live/templates/getSingleVisitSummary.twig
@@ -5,8 +5,8 @@
{% endmacro %}
{% import _self as macros %}
{% if showLocation|default(false) %}
-<div class="visitor-profile-latest-visit-loc">
- <img src="{{ visitData.countryFlag }}" title="{{ visitData.country }}"/>&nbsp;<span>{% if visitData.city is not empty %}{{ visitData.city }}{% else %}{{ visitData.country }}{% endif %}</span>
+<div class="visitor-profile-latest-visit-loc" title="{{ visitData.location }}">
+ <img src="{{ visitData.countryFlag }}"/>&nbsp;<span>{% if visitData.city is not empty %}{{ visitData.city }}{% else %}{{ visitData.country }}{% endif %}</span>
</div>
{% endif %}
<div class="visitor-profile-latest-visit-column">
diff --git a/plugins/Live/templates/getVisitorProfilePopup.twig b/plugins/Live/templates/getVisitorProfilePopup.twig
index b81ad5163d..d57bb58cb0 100644
--- a/plugins/Live/templates/getVisitorProfilePopup.twig
+++ b/plugins/Live/templates/getVisitorProfilePopup.twig
@@ -71,7 +71,9 @@
<h1>{{ 'UserCountry_Location'|translate }}</h1>
<p>
{%- for entry in visitorData.countries -%}
- {{- 'Live_VisitsFrom'|translate('<strong>', entry.nb_visits, '</strong>')|raw }} <img src="{{ entry.flag }}" title="{{ entry.prettyName }}"/>&nbsp;{{ entry.prettyName }}{% if not loop.last %}, {% endif %}
+ {% set entryVisits %}<strong>{% if entry.nb_visits == 1 %}{{ 'General_OneVisit'|translate }}{% else %}{{ 'General_NVisits'|translate(entry.nb_visits) }}{% endif %}</strong>{% endset %}
+ {% set entryCountry %}<img src="{{ entry.flag }}" title="{{ entry.prettyName }}"/>&nbsp;{{ entry.prettyName }}{% endset %}
+ {{- 'General_XFromY'|translate(entryVisits, entryCountry)|raw -}}{% if not loop.last %}, {% endif %}
{%- endfor %}
<a class="visitor-profile-show-map" href="#">({{ 'Live_ShowMap_js'|translate|replace({' ': '&nbsp;'})|raw }})</a>
</p>