コード例 #1
0
ファイル: cycle.php プロジェクト: neostoic/healthyfood
 public static function create($system_venue_id, $frequency = 'hourly')
 {
     // add hourly tracking by default at the moment.
     $Cycle = new \Model_Tracking_Cycle();
     $Cycle->object_id = $system_venue_id;
     $Cycle->frequency = $frequency;
     // 2do: manage timezone based tracking
     // $Cycle->TZ = 'ET';
     $Cycle->save();
 }
コード例 #2
0
ファイル: keyword.php プロジェクト: neostoic/healthyfood
 public static function addKeywordToDB($value)
 {
     if (self::keywordExists($value)) {
         return false;
     }
     $system_id = \Collection\Singleton::create('keyword');
     $Keyword = new \Model_Keyword();
     $Keyword->id = $system_id;
     $Keyword->value = $value;
     $Keyword->count = 0;
     $Keyword->save();
     // Tracking_Cylce::create($system_id, 'hourly');
     $Cycle = new \Model_Tracking_Cycle();
     $Cycle->object_id = $system_id;
     $Cycle->frequency = 'hourly';
     $Cycle->save();
     return true;
 }
コード例 #3
0
ファイル: spider.php プロジェクト: neostoic/healthyfood
 public function searchForLocations($lat = 40.761821, $lng = -73.974895, $radius = 1000, $query = '', $region_id = false)
 {
     $FoursquareClient = new \Foursquare\Client();
     // get a setting of category IDs
     $categoryId = $this->getVenueCategoryIds($this->active_category);
     if (!$categoryId) {
         return false;
     }
     // get locations surrounding lat/lng geo point.
     $locations = $FoursquareClient->get('searchLocation', $lat . ',' . $lng, $radius, 50, $categoryId, $query);
     if (!isset($locations->response)) {
         return;
     }
     foreach ($locations->response->venues as $key => $venue) {
         $response = \Collection\Venue::saveVenueJsonToDB($venue, $region_id);
         if (!$response) {
             // skip this venue if it already exists
             $this->debugMessage('Venue already exists: ' . $venue->name . ' / ' . $venue->id);
             continue;
         }
         $this->debugMessage($response['log']);
         // create a default "1 scan per hour" entry to the tracking cycle
         // \Collection\Tracking_Cylce::create($response['system_venue_id'], 'hourly');
         $Cycle = new \Model_Tracking_Cycle();
         $Cycle->object_id = $response['system_venue_id'];
         $Cycle->frequency = 'hourly';
         // 2do: manage timezone based tracking
         // $Cycle->TZ = 'ET';
         $Cycle->save();
         // if we didn't get back a stats array, an error occured
         if (!is_array($response['stats'])) {
             $this->CliOutput('error', 'Failure: ' . $response['stats']);
         } else {
             $this->debugMessage('Stats: ' . implode(', ', $response['stats']));
         }
     }
 }