示例#1
0
 /**
  * @before _secure, memberLayout
  */
 public function stats($keyword_id)
 {
     $keyword = \Keyword::first(array("id = ?" => $keyword_id, "serp = ?" => false), array("link", "user_id", "id"));
     $this->_authority($keyword);
     Shared\Service\Social::record($keyword);
     $end_date = RequestMethods::get("enddate", date("Y-m-d"));
     $start_date = RequestMethods::get("startdate", date("Y-m-d", strtotime($end_date . "-7 day")));
     $social_media = RequestMethods::get("media", "facebook");
     $this->seo(array("title" => "Serp | Stats", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $socials = Registry::get("MongoDB")->socials;
     $start_time = strtotime($start_date);
     $end_time = strtotime($end_date);
     $obj = array();
     $records = $socials->find(array('created' => array('$gte' => new MongoDate($start_time), '$lte' => new MongoDate($end_time)), 'social_media' => (string) $social_media, 'keyword_id' => (int) $keyword->id));
     foreach ($records as $r) {
         $position = $r['count'];
         $media = array();
         $media['count_type'] = $r['count_type'];
         $media['social_media'] = $r['social_media'];
         $obj[] = array('y' => date('Y-m-d', $r['created']->sec), 'a' => $position);
     }
     $view->set("keyword", $keyword)->set("label", $media['count_type'])->set("social", array("type" => $media['count_type'], "media" => $media['social_media']))->set("data", ArrayMethods::toObject($obj));
 }
示例#2
0
 protected function _social()
 {
     try {
         $keywords = Keyword::all(array("live = ?" => true, "serp = ?" => false), array("id", "user_id", "link"));
         foreach ($keywords as $k) {
             Shared\Service\Social::record($k);
             sleep(2);
             // to prevent bandwidth load
         }
     } catch (\Exception $e) {
         $this->log(print_r($e));
         $this->log("Error in getting Social Link Stats");
     }
 }