コード例 #1
0
ファイル: AJAX.php プロジェクト: bryandease/VuFind-Plus
 /**
  * Recent activity includes users, searches done, events, and page views
  */
 function getRecentActivity()
 {
     global $analytics;
     $interval = isset($_REQUEST['interval']) ? $_REQUEST['interval'] : 10;
     $curTime = time();
     $activityByMinute = array();
     $analyticsSession = $analytics->getSessionFilters();
     if ($analyticsSession == null) {
         $analyticsSession = new Analytics_Session();
     }
     $analyticsSession->selectAdd('count(id) as numActiveUsers');
     $analyticsSession->whereAdd('lastRequestTime > ' . ($curTime - $interval));
     //$analyticsSession->whereAdd("lastRequestTime <= $curTime");
     if ($analyticsSession->find(true)) {
         $activityByMinute['activeUsers'] = $analyticsSession->numActiveUsers;
     } else {
         $activityByMinute['activeUsers'] = 0;
     }
     $pageView = new Analytics_PageView();
     $pageView->selectAdd('count(id) as numPageViews');
     $pageView->whereAdd("pageEndTime > " . ($curTime - $interval));
     //$pageView->whereAdd("pageEndTime <= $curTime");
     if ($pageView->find(true)) {
         $activityByMinute['pageViews'] = $pageView->numPageViews;
     } else {
         $activityByMinute['pageViews'] = 0;
     }
     $searches = new Analytics_Search();
     $searches->selectAdd('count(id) as numSearches');
     $searches->whereAdd("searchTime > " . ($curTime - $interval));
     //$searches->whereAdd("searchTime <= $curTime");
     if ($searches->find(true)) {
         $activityByMinute['searches'] = $searches->numSearches;
     } else {
         $activityByMinute['searches'] = 0;
     }
     $events = new Analytics_Event();
     $events->selectAdd('count(id) as numEvents');
     $events->whereAdd("eventTime > " . ($curTime - $interval));
     //$events->whereAdd("eventTime <= $curTime");
     if ($events->find(true)) {
         $activityByMinute['events'] = $events->numEvents;
     } else {
         $activityByMinute['events'] = 0;
     }
     return $activityByMinute;
 }
コード例 #2
0
ファイル: Searches.php プロジェクト: bryandease/VuFind-Plus
 function launch()
 {
     global $interface;
     global $analytics;
     //Setup filters
     $this->setupFilters();
     $topSearches = $analytics->getTopSearches(true);
     $interface->assign('topSearches', $topSearches);
     $session = $analytics->getSessionFilters();
     $search = new Analytics_Search();
     $search->selectAdd();
     $search->selectAdd("count(analytics_search.id) as numSearches");
     $search->selectAdd("lookfor");
     if ($session != null) {
         $search->joinAdd($session);
     }
     $search->whereAdd("numResults = 0");
     $search->groupBy('lookfor');
     $search->orderBy('numSearches DESC');
     $search->limit(0, 20);
     $search->find();
     $topNoHitSearches = array();
     while ($search->fetch()) {
         if (!is_null($search->lookfor) || strlen(trim($search->lookfor)) > 0) {
             $topNoHitSearches[] = "{$search->lookfor} ({$search->numSearches})";
         } else {
             $topNoHitSearches[] = "<blank> ({$search->numSearches})";
         }
     }
     $interface->assign('topNoHitSearches', $topNoHitSearches);
     $search = new Analytics_Search();
     $search->selectAdd();
     $search->selectAdd("lookfor");
     $search->selectAdd("MAX(searchTime) as lastSearch ");
     if ($session != null) {
         $search->joinAdd($session);
     }
     $search->groupBy('lookfor');
     $search->orderBy('lastSearch DESC');
     $search->limit(0, 20);
     $search->find();
     $latestSearches = array();
     while ($search->fetch()) {
         if (!is_null($search->lookfor) || strlen(trim($search->lookfor)) > 0) {
             $latestSearches[] = "{$search->lookfor} {$search->searchTime}";
         } else {
             $latestSearches[] = "<blank>";
         }
     }
     $interface->assign('latestSearches', $latestSearches);
     $search = new Analytics_Search();
     $search->selectAdd();
     $search->selectAdd("lookfor");
     $search->selectAdd("MAX(searchTime) as lastSearch ");
     if ($session != null) {
         $search->joinAdd($session);
     }
     $search->whereAdd("numResults = 0");
     $search->groupBy('lookfor');
     $search->orderBy('lastSearch DESC');
     $search->limit(0, 20);
     $search->find();
     $latestNoHitSearches = array();
     while ($search->fetch()) {
         if (!is_null($search->lookfor) || strlen(trim($search->lookfor)) > 0) {
             $latestNoHitSearches[] = "{$search->lookfor} {$search->searchTime}";
         } else {
             $latestNoHitSearches[] = "<blank>";
         }
     }
     $interface->assign('latestNoHitSearches', $latestNoHitSearches);
     $interface->setPageTitle('Report - Searches');
     $interface->setTemplate('searches.tpl');
     $interface->display('layout.tpl');
 }
コード例 #3
0
ファイル: Analytics.php プロジェクト: bryandease/VuFind-Plus
 function getTopSearches($forGraph)
 {
     $search = new Analytics_Search();
     $search->selectAdd();
     $search->selectAdd("count(analytics_search.id) as numSearches");
     $search->selectAdd("lookfor");
     $session = $this->getSessionFilters();
     if ($session != null) {
         $search->joinAdd($session);
     }
     $search->addDateFilters();
     $search->whereAdd("numResults > 0");
     $search->groupBy('lookfor');
     $search->orderBy('numSearches DESC');
     if ($forGraph) {
         $search->limit(0, 20);
     } else {
         $search->limit(0, 50);
     }
     $search->find();
     $topSearches = array();
     while ($search->fetch()) {
         if (!is_null($search->lookfor) && strlen(trim($search->lookfor)) > 0) {
             $searchTerm = $search->lookfor;
         } else {
             $searchTerm = "&lt;blank&gt;";
         }
         if ($forGraph) {
             $topSearches[] = "{$searchTerm} ({$search->numSearches})";
         } else {
             $topSearches[] = array($searchTerm, $search->numSearches);
         }
     }
     return $topSearches;
 }