Beispiel #1
0
 public static function getOrCreateVenueRelation($keyword_id, $venue_id)
 {
     if ($entry = \Model_Keyword_Venue::query()->where('keyword_id', $keyword_id)->where('venue_id', $venue_id)->get_one()) {
         return $entry;
     }
     $system_id = \Collection\Singleton::create('keyword');
     $entry = new \Model_Keyword_Venue();
     $entry->id = $system_id;
     $entry->keyword_id = $keyword_id;
     $entry->venue_id = $venue_id;
     $entry->count = 0;
     $entry->save();
     return $entry;
 }
Beispiel #2
0
 public static function saveVenueJsonToDB($venue, $region_id = NULL)
 {
     // skip this venue if it already exists
     if (self::venueFoursquareIdExists($venue->id)) {
         return false;
     }
     $response = array();
     // create a new global identifier
     $system_venue_id = \Collection\Singleton::create('venue');
     $response['system_venue_id'] = $system_venue_id;
     // create a base venue entry
     self::createVenue($system_venue_id, $venue, $region_id);
     $response['log'] = 'Added new venue: ' . $venue->name . ' / ' . $venue->id;
     // save foursquare relevant data
     self::createOrUpdateVenueMetaFoursquare($system_venue_id, $venue);
     // save general meta data for this venue
     self::createVenueMetaCommon($system_venue_id, $venue);
     // write initial stats to DB > $stats array
     $response['stats'] = self::saveVenueStats($system_venue_id, $venue);
     return $response;
 }
Beispiel #3
0
 public static function getInternalUserId($interaction)
 {
     // 2do: prevent duplicate querying
     $query = \DB::select('*')->from('user_meta_instagram');
     $query->join('user');
     $query->on('user.id', '=', 'user_meta_instagram.id');
     $query->where('instagram_user_id', $interaction->user->id);
     $results = $query->as_object()->execute();
     if ($results && isset($results[0])) {
         return $results[0]->id;
     }
     $system_user_id = \Collection\Singleton::create('interaction');
     $BaseUser = new \Model_User();
     $BaseUser->id = $system_user_id;
     $BaseUser->username = $interaction->user->username;
     $BaseUser->save();
     $InstagramUser = new \Model_User_Meta_Instagram();
     $InstagramUser->id = $system_user_id;
     $InstagramUser->username = $interaction->user->username;
     $InstagramUser->instagram_user_id = $interaction->user->id;
     $InstagramUser->save();
     return $system_user_id;
 }