Piwik\Plugins\Live\API::getLastVisitsDetails PHP Method

getLastVisitsDetails() public method

Returns the last visits tracked in the specified website You can define any number of filters: none, one, many or all parameters can be defined
public getLastVisitsDetails ( integer $idSite, boolean | string $period = false, boolean | string $date = false, boolean | integer $segment = false, boolean | integer $countVisitorsToFetch = false, boolean | integer $minTimestamp = false, boolean $flat = false, boolean $doNotFetchActions = false ) : DataTable
$idSite integer Site ID
$period boolean | string Period to restrict to when looking at the logs
$date boolean | string Date to restrict to
$segment boolean | integer (optional) Number of visits rows to return
$countVisitorsToFetch boolean | integer DEPRECATED (optional) Only return the last X visits. Please use the API paramaeter 'filter_offset' and 'filter_limit' instead.
$minTimestamp boolean | integer (optional) Minimum timestamp to restrict the query to (useful when paginating or refreshing visits)
$flat boolean
$doNotFetchActions boolean
return Piwik\DataTable
    public function getLastVisitsDetails($idSite, $period = false, $date = false, $segment = false, $countVisitorsToFetch = false, $minTimestamp = false, $flat = false, $doNotFetchActions = false)
    {
        Piwik::checkUserHasViewAccess($idSite);
        if ($countVisitorsToFetch !== false) {
            $filterLimit = (int) $countVisitorsToFetch;
            $filterOffset = 0;
        } else {
            $filterLimit = Common::getRequestVar('filter_limit', 10, 'int');
            $filterOffset = Common::getRequestVar('filter_offset', 0, 'int');
        }
        $filterSortOrder = Common::getRequestVar('filter_sort_order', false, 'string');
        $dataTable = $this->loadLastVisitorDetailsFromDatabase($idSite, $period, $date, $segment, $filterOffset, $filterLimit, $minTimestamp, $filterSortOrder, $visitorId = false);
        $this->addFilterToCleanVisitors($dataTable, $idSite, $flat, $doNotFetchActions);
        $filterSortColumn = Common::getRequestVar('filter_sort_column', false, 'string');
        if ($filterSortColumn) {
            $this->logger->warning('Sorting the API method "Live.getLastVisitDetails" by column is currently not supported. To avoid this warning remove the URL parameter "filter_sort_column" from your API request.');
        }
        // Usually one would Sort a DataTable and then apply a Limit. In this case we apply a Limit first in SQL
        // for fast offset usage see https://github.com/piwik/piwik/issues/7458. Sorting afterwards would lead to a
        // wrong sorting result as it would only sort the limited results. Therefore we do not support a Sort for this
        // API
        $dataTable->disableFilter('Sort');
        $dataTable->disableFilter('Limit');
        // limit is already applied here
        return $dataTable;
    }