def post(self): oauth_token = self.request.get('oauth_token') api = base.api.Api(oauth_token) checkins = data.checkins.Checkins.get_by_foursquare_id( self.request.get('foursquare_id')) direction = self.request.get('direction') logging.info('Updating checkins (%d so far) for %s (direction: %s)', checkins.length(), checkins.foursquare_id, direction) if direction == 'forward': new_checkin_count = checkins.fetch_newer(api) else: new_checkin_count = checkins.fetch_older(api) logging.info('Got %d new checkins, %d total', new_checkin_count, checkins.length()) if not new_checkin_count: checkins.is_updating = False try: checkins.put() except (db.BadRequestError, apiproxy_errors.RequestTooLargeError), err: logging.exception(err) logging.error( '%s has too many checkins (%d), dropping some', checkins.foursquare_id, checkins.length()) checkins.drop_old_checkins() logging.error( '%s now has %d checkins', checkins.foursquare_id, checkins.length()) checkins.put()
def _get_signed_in(self): checkins = self._get_checkins_for_update() if checkins.update_needed(): direction = checkins.length() and 'forward' or 'backward' checkins.is_updating = True checkins.put() update_session = \ data.session.Session.get_by_foursquare_id(checkins.foursquare_id) taskqueue.add( queue_name='update-checkins', url='/tasks/checkins/update', params={ 'oauth_token': update_session.oauth_token, 'foursquare_id': checkins.foursquare_id, 'direction': direction }) self.response.out.write('OK')
def _get_signed_in(self): checkins = self._get_checkins() checkins.clear() checkins.put() self.response.out.write('OK')