Ejemplo n.º 1
0
    # retrieve the list of venues from the database
    venues = dbw.get_venues_in_city( city_code )
    logging.info( u'CHK_MON retrieved %d venues from database for %s' % ( len(venues), city_code ) )

    # loop forever checking the venues for checkins
    while True:
        count_venues = 0
        count_checkins = 0
        count_venues_with_checkins = 0
        logging.info( u'CHK_MON start running checkin crawl in %s' % city_code )
        # log the start of a crawl
        crawl_string = 'MONITOR_CHECKINS_' + city_code
        dbw.add_crawl_to_database( crawl_string, 'START', now.now( ) )
        for venue in venues:
            if dbw.is_active( venue ):
                location = venue.location
                lat = location.latitude
                lng = location.longitude
                point = Point(lat,lng)
                if polygon.contains(point):
                    logging.info( u'CHK_MON %s: retrieve details for venue: %s' % ( city_code, venue.name ) )
                    response, success = get_venue_details( venue.foursq_id, userless=True )
                    if success:
                        count_venues = count_venues + 1
                        v = response.get( 'response' )
                        v = v.get( 'venue' )
                        hereNow = v.get( 'hereNow' )
                        count = hereNow.get( 'count' )
                        logging.info( u'CHK_MON %s: checkins found: %d' % ( city_code, count ) )
                        if count > 0: