/** * display monthly stats overview * @param sfWebRequest $request */ public function executeMonthly(sfWebRequest $request) { $this->getResponse()->setSlot('js_document_ready', $this->getPartial('oldstats/js_init_visit_history.js')); $this->pMonth = $request->getParameter('month', date('Y-m')); $this->pHost = $request->getParameter('host', null); $this->pSortCat = $request->getParameter('sort', 'host'); $this->pSortOrder = $request->getParameter('order', 'asc'); $this->pPage = $request->getParameter('page', 1); $lQuery = '&month=' . $this->pMonth . '&host=' . $this->pHost . '&sort=' . $this->pSortCat . '&order=' . $this->pSortOrder; $this->pQuery = $lQuery; $this->lHostCount = VisitTable::countHostsForMonth($this->pMonth, $this->pHost); $this->lVisits = VisitTable::getMonthlyStatistics($this->pMonth, $this->pHost, $this->pPage, $this->pSortCat, $this->pSortOrder); }
/** * Executes advertisement action * * @param sfRequest $request A request object */ public function executeAdvertisement(sfWebRequest $request) { $domain = $request->getParameter("domain", "http://spreadly.com/"); $domain = urldecode($domain); $host = parse_url($domain, PHP_URL_HOST); $scheme = parse_url($domain, PHP_URL_SCHEME); $visit = VisitTable::getMonthlyStatistics(date('Y-m', strtotime("-1 month")), $host); $counter = 0; if (is_array($visit) && count($visit) > 0) { if (array_key_exists("pis_total", $visit[0])) { $counter = $visit[0]["pis_total"]; } } $this->domain = $scheme . "://" . $host; $this->counter = $counter; }
private function calc($range, $lastRange) { $data = array(); $data['current_user_count'] = UserTable::getInstance()->countByRange($range[0], $range[1]); $data['last_user_count'] = UserTable::getInstance()->countByRange($lastRange[0], $lastRange[1]); $data['user_count_delta'] = $this->delta($data['current_user_count'], $data['last_user_count']); $data['current_stats_user_count'] = SfGuardUserTable::getInstance()->countByRange($range[0], $range[1]); $data['last_stats_user_count'] = SfGuardUserTable::getInstance()->countByRange($lastRange[0], $lastRange[1]); $data['stats_user_count_delta'] = $this->delta($data['current_stats_user_count'], $data['last_stats_user_count']); $data['current_likes_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countByRange($range[0], $range[1]); $data['last_likes_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countByRange($lastRange[0], $lastRange[1]); $data['likes_count_delta'] = $this->delta($data['current_likes_count'], $data['last_likes_count']); $data['current_cbl_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countCBLByRange($range[0], $range[1]); $data['last_cbl_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countCBLByRange($lastRange[0], $lastRange[1]); $data['cbl_count_delta'] = $this->delta($data['current_cbl_count'], $data['last_cbl_count']); $data['current_domain_count'] = DomainProfileTable::getInstance()->countByRange($range[0], $range[1]); $data['last_domain_count'] = DomainProfileTable::getInstance()->countByRange($lastRange[0], $lastRange[1]); $data['domain_count_delta'] = $this->delta($data['current_domain_count'], $data['last_domain_count']); $data['current_verified_domain_count'] = DomainProfileTable::getInstance()->countVerifiedByRange($range[0], $range[1]); $data['last_verified_domain_count'] = DomainProfileTable::getInstance()->countVerifiedByRange($lastRange[0], $lastRange[1]); $data['verified_domain_count_delta'] = $this->delta($data['current_verified_domain_count'], $data['last_verified_domain_count']); $data['current_stats'] = MongoManager::getStatsDm()->getRepository('Documents\\AnalyticsActivity')->findOnlyByRange($range[0], $range[1]); $data['last_stats'] = MongoManager::getStatsDm()->getRepository('Documents\\AnalyticsActivity')->findOnlyByRange($lastRange[0], $lastRange[1]); $data['current_stats'] = $data['current_stats'] && $data['current_stats']->hasNext() ? $data['current_stats']->getNext() : null; $data['last_stats'] = $data['last_stats'] && $data['last_stats']->hasNext() ? $data['last_stats']->getNext() : null; $data['current_clickback_count'] = $data['current_stats'] ? $data['current_stats']['value']['cb'] : 0; $data['last_clickback_count'] = $data['last_stats'] ? $data['last_stats']['value']['cb'] : 0; $data['clickback_count_delta'] = $this->delta($data['current_clickback_count'], $data['last_clickback_count']); $data['current_media_penetration_count'] = $data['current_stats'] ? $data['current_stats']['value']['mp'] : 0; $data['last_media_penetration_count'] = $data['last_stats'] ? $data['last_stats']['value']['mp'] : 0; $data['media_penetration_count_delta'] = $this->delta($data['current_media_penetration_count'], $data['last_media_penetration_count']); $data['share_distribution'] = $data['current_stats'] ? array($data['current_stats']['value']['s']['facebook'] ? $data['current_stats']['value']['s']['facebook']['l'] : 0, $data['current_stats']['value']['s']['twitter'] ? $data['current_stats']['value']['s']['twitter']['l'] : 0, $data['current_stats']['value']['s']['linkedin'] ? $data['current_stats']['value']['s']['linkedin']['l'] : 0, $data['current_stats']['value']['s']['google'] ? $data['current_stats']['value']['s']['google']['l'] : 0) : array(0, 0, 0, 0); $data['share_distribution_labels'] = array('Fb:' . $data['share_distribution'][0], 'Tw:' . $data['share_distribution'][1], 'Li:' . $data['share_distribution'][2], 'Go:' . $data['share_distribution'][3]); if ($this->range == 'today' || $this->range == 'yesterday') { $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\ActivityStats")->findByRangeGroupByDay($range[0], $range[1]); $h = null; if ($lActivityStats && $lActivityStats->hasNext()) { $temp = $lActivityStats->getNext(); $h = $temp['value']['h']; unset($h['php_ckuf']); } $data['current_likes_range'] = $h ? $h : array(); $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\DealStats")->findByRangeGroupByDay($range[0], $range[1]); $h = null; if ($lActivityStats && $lActivityStats->hasNext()) { $temp = $lActivityStats->getNext(); $h = $temp['value']['h']; unset($h['php_ckuf']); } $data['current_deals_range'] = $h ? $h : array(); } else { $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\ActivityStats")->findLikesByRangeGroupByDay($range[0], $range[1]); if ($lActivityStats) { $lActivityStats = $lActivityStats->toArray(); $data['current_likes_range'] = array_values($this->padLikes($lActivityStats, date('c', $range[0]), date('c', $range[1]))); $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\DealStats")->findLikesByRangeGroupByDay($range[0], $range[1]); $lActivityStats = $lActivityStats->toArray(); $data['current_deals_range'] = array_values($this->padLikes($lActivityStats, date('c', $range[0]), date('c', $range[1]))); } } $data['top_users'] = array_slice(MongoManager::getStatsDm()->getRepository("Documents\\AnalyticsActivity")->groupByUsers($range[0], $range[1]), 0, 5); $data['top_hosts'] = array_slice(MongoManager::getStatsDm()->getRepository("Documents\\AnalyticsActivity")->groupByHosts($range[0], $range[1]), 0, 5); $data['top_urls'] = array_slice(MongoManager::getStatsDm()->getRepository("Documents\\AnalyticsActivity")->groupByUrls($range[0], $range[1]), 0, 5); //$cb = new Chartbeat(); //$data['current_popup_visitors_count'] = $cb->getVisitorsByDate($this->range); $data['current_pi_count'] = intval(VisitTable::countPisForDay($range[0])); $data['last_pi_count'] = intval(VisitTable::countPisForDay($lastRange[0])); $data['pi_count_delta'] = $this->delta($data['current_pi_count'], $data['last_pi_count']); $data['current_conversion'] = $this->conversion($data['current_likes_count'], $data['current_pi_count']); $data['last_conversion'] = $this->conversion($data['last_likes_count'], $data['last_pi_count']); $data['conversion_delta'] = $this->delta($data['current_conversion'], $data['last_conversion']); return $data; }