Exemplo n.º 1
0
        def place_callback(data):
            # Generate a score for each venue.
            process_businesses(data)

            # Get the place with the best score.
            pick = self.redis.zrevrange(place_scores, 0, 1)[0]

            # Get the reasons for picking
            pick_reasons = self.redis.smembers(place_reasons_key % pick)

            # Delete all the used keys from Redis.
            map(self.redis.delete, self.reason_keys)
            self.redis.delete(place_scores)

            def pick_output(data):
                self.write({"result": "okay",
                            "business": data,
                            "reasons": list(pick_reasons),
                            "stars": data["rating"] if "rating" in data else 3})
                self.finish()
                print "Finished"

            print "Picked %s" % pick
            business_data(pick_output, pick, redis=self.redis)
            self.redis.lpush("places::history::%s" % self.email, pick)
Exemplo n.º 2
0
 def get_tiny_business(choice):
     id_, score = choice
     data = business_data(None, id_, self.redis)
     return {"name": data["name"],
             "points": score,
             "id": id_,
             "latitude": data["location"]["coordinate"]["latitude"],
             "longitude": data["location"]["coordinate"]["longitude"]}
Exemplo n.º 3
0
 def get_tiny_business(choice):
     id_, score = choice
     return business_data(None, id_, self.redis)["name"], score, id_