def remove_old_page_id(self, page_id):
     try:
         #import pdb; pdb.set_trace()
         self.remove('checkin', {"page_id": long(page_id)})
         self.remove('place', {"page_id": long(page_id)})
         self.remove('place_similar', {"page_id": long(page_id)})
         # source_page_ids will be cleaned when periodic save is run
         # self.remove('place_similar', {"sourcepage_ids": $in long(page_id)})
         self.remove('preference', {"page_id": long(page_id)})
     except:
         util.log_exception_error(logger, "Unexpected error at remove_old_page_id(%s) failed." % page_id)
         raise
Beispiel #2
0
                else:
                    raise SyncFacebookDBException("Page ID of place and page did not match.")
                location_list[idx]['last_update'] = datetime.now()

            # save locations
            logger.debug("\n\nlocation_list to be saved in mongodb: %s", location_list)
            self._persistence.save_list_objects('place', location_list)
    
            # save user's likes
            self.save_likes(access_token, me_elem['uid'])
            
            rate_list = self._persistence.trigger_fill_coll_preference(me_elem['uid'], friend_id_list)
            #import pdb; pdb.set_trace()
            self.query_save_similar_places(rate_list, access_token, client_loc_longitude, client_loc_latitude)
        except Exception, e:
            util.log_exception_error(logger, "query_fb_and_save failed. %s" % e)
        except:
            util.log_exception_error(logger, "Unexpected error at query_fb_and_save failed.")
            raise
        return


    def query_save_similar_places(self, rate_list, user_access_token, client_loc_longitude, client_loc_latitude):
        #import pdb; pdb.set_trace()
        logger.info("rate_list: %s, user_access_token:%s, client_loc_longitude:%s, client_loc_latitude:%s" % (rate_list, user_access_token, client_loc_longitude, client_loc_latitude))
        try:
            client_loc_longitude = float(client_loc_longitude)
            client_loc_latitude = float(client_loc_latitude)
        except:
            logger.error("client_loc_longitude:%s or client_loc_latitude:%s is not number" % (client_loc_longitude, client_loc_latitude))