Esempio n. 1
0
 def __init__(self, access_token=None):
     self.logger = get_logger(__name__)
     self.fsq = Foursquare(
         client_id=FOURSQUARE_CLIENT_ID,
         client_secret=FOURSQUARE_CLIENT_SECRET,
         redirect_uri=LOGIN_REDIRECT_URI
     )
     if access_token is not None:
         self.set_token(access_token)
     self.cache = Cache()
Esempio n. 2
0
from operator import attrgetter
from itertools import chain

from gevent.pool import Pool

from fsqaway.config import GEVENT_POOL_SIZE
from fsqaway.log import get_logger
from fsqaway.dao.models import Venue
from fsqaway.dao.database import db


THRESHOLD = 5
SEARCH_CATEGORY_LIMIT = 15
REVIEWS_THRESHOLD = 1

logger = get_logger(__name__)


class Magic(object):
    def __init__(self, foursquare_api):
        self.api = foursquare_api

    def get_venues_magically(self):
        categories = self.api.get_categories_filter()
        pool = Pool(GEVENT_POOL_SIZE)
        result = pool.map(
            lambda x: self.api.search(
                search_term=x,
                categories=categories,
                per_category_limit=SEARCH_CATEGORY_LIMIT
            ).get('venues', []),