def search(self, win_player_id): if self.r.exists(win_player_id) != 0: competitions = pickle.loads(self.r.get(win_player_id)) else: query = {} if win_player_id != '0': query["winner._id"] = win_player_id # ObjectId(request.GET['client_id']) competitions = list(self.competitions.find(query)) self.r.set(win_player_id, pickle.dumps(competitions)) new_competitions = [] for x in competitions: new_competitions.append(competitionFromDict(x)) return new_competitions
def getCompetition(self, id): return competitionFromDict(self.competitions.find_one({'_id': id}))
def getCompetitionsList(self): competitions = [] comp = self.competitions.find() for x in comp: competitions.append(competitionFromDict(x)) return competitions