def get_high_scores(self, request): '''Order scores by attempts remaining for high score list''' scores = Score.query() scores = scores.order(-Score.attempts_remaining) if request.number_of_results: number = int(request.number_of_results) scores = scores.fetch(number) return ScoreForms(items=[score.to_form() for score in scores]) else: return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """Return high scores""" if request.number_of_results: return ScoreForms(items=[score.to_form() for score in Score.query().order(-Score.winner, -Score.user_steps).\ fetch(request.number_of_results)]) else: return ScoreForms(items=[ score.to_form() for score in Score.query().order( -Score.winner, -Score.user_steps) ])
def get_high_scores(self, request): # order scores descending order by attempts remaining # more attempts equal better scores = Score.query().order(-Score.attempts_remaining) if request.number_of_results: return ScoreForms(items=[ score.to_form() for score in scores.fetch(limit=request.number_of_results) ]) else: return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """Return ordered high scores based on 1.more won 2.less guesses number""" qo = ndb.QueryOptions(limit=request.limitation) scoreQuery = Score.query().order(-Score.won, Score.guesses) scoreList = scoreQuery.fetch(10, options=qo) return ScoreForms(items=[score.to_form() for score in scoreList])
def get_high_scores(self, request): """ Returns the leader-board for hangman """ scores = Score.query(Score.won == True).order(Score.guesses).fetch( request.number_of_results) return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """Returns all of a User's scores sorted by score""" scores = Score.query().order(Score.guesses) return ScoreForms(items=[ score.to_form() for score in scores.fetch(request.number_of_results) ])
def get_user_scores(self, request): """Returns all of an individual User's scores""" user = User.query(User.name == request.user_name).get() if not user: raise endpoints.NotFoundException('User not exist!') scores = Score.query(Score.user == user.key) return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self,request): """Return all scores ordered by total points""" if request.number_of_results: scores = Score.query(Score.won == True).order(Score.attempts_allowed,Score.guesses).fetch(request.number_of_results) else: scores = Score.query(Score.won == True).order(Score.attempts_allowed,Score.guesses).fetch() return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """Returns high scores. Number of scores returned is limited by an optional parameter, number_of_results""" scores = Score.query(Score.won == True).order(-Score.score).fetch( limit=request.number_of_results) return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """Return high scores.""" if request.number_of_results > 0: scores = Score.query().order(Score.guesses).fetch( request.number_of_results) else: scores = Score.query().order(Score.guesses) return ScoreForms(items=[score.to_form() for score in scores])
def get_scores(self, request): """Return all scores""" player = Player.get_player_by_name(request.name) if not player: raise endpoints.NotFoundException('Player does not exist') scores = Score.query(ndb.OR(Score.playerOne == player.key, Score.playerTwo == player.key)) return ScoreForms(items=[score.copy_score_to_form() for score in scores])
def get_user_score(self, request): """Return all scores of a user""" user = User.query(User.name == request.user_name).get() if not user: raise endpoints.NotFoundException( 'A user with that name does not exist!') scores = Score.query(Score.user == user.key) return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """Get high scores in decreasing order""" if not request.number_of_result: number = DEAFULT_NUMBER_OF_REQUEST else: number = request.number_of_result scores = Score.query().order(-Score.score).fetch(limit=number) return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """Return highest scores""" scores = Score.query() scores = scores.order(-Score.score) if request.limit > 0: scores = scores.fetch(request.limit) return ScoreForms(items=[score.to_form() for score in scores])
def get_user_scores(self, request): """Return all of an individual User's game scores.""" user = User.query(User.name == request.user_name).get() if not user: raise endpoints.NotFoundException( 'A User with that name does not exist!') qResults = Game.query(Game.user == user.key) return ScoreForms(scores=[game.to_score_report() for game in qResults])
def get_user_scores(self, request): """Returns all of an individual User's scores""" user = User.query(User.screen_name == request.user_name).get() if not user: raise endpoints.NotFoundException( 'A User with that name does not exist!') scores = Score.query(ancestor=user.key) return ScoreForms(scores=[score.to_form() for score in scores])
def get_high_scores(self, request): """Return all scores""" if request.quantity_of_scores: # check is positive integer if request.quantity_of_scores < 1: raise endpoints.BadRequestException( 'Quantity of Scores most be an positive integer') # return limited set of scores, according to quantity provided return ScoreForms( items=[score.to_form() for score in Score.query( ).order(-Score.holes_remaining).fetch( request.quantity_of_scores)]) else: # no quantity provided, so return all scores return ScoreForms(items=[score.to_form() for score in Score.query().order( -Score.holes_remaining)])
def get_user_scores(self, request): """Returns all of an individual User's scores""" user = User.get_user_by_name(request.user_name) if not user: raise endpoints.NotFoundException( 'A User with that name does not exist!') scores = Score.query( ndb.OR(Score.user_x == user.key, Score.user_o == user.key)) return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """Return all scores ordered by total points""" if request.limit: scores = Score.query().order(-Score.num_of_wons).fetch( request.limit) else: scores = Score.query().order(-Score.num_of_wons).fetch() return ScoreForms(items=[score.to_form() for score in scores])
def get_user_scores(self, request): """Returns all of an individual User's scores""" user = self._getInfoFromUser() if not user: raise endpoints.NotFoundException('User is not signed in!') scores = Score.query( ndb.OR(Score.winning_user == user.key, Score.losing_user == user.key)) return ScoreForms(items=[score.to_form() for score in scores])
def get_best_scores(self, request): """Return the best game results""" scores = Score.query().order(Score.moves).fetch( int(request.number_of_results)) if not scores: raise endpoints.NotFoundException("No scores found") items = [score.to_form() for score in scores] return ScoreForms(items=items)
def get_high_scores(self, request): """Retrieve the high scores to date. Optionally accepts result_num which is the number of results wanted.""" sq = Score.query().order(-Score.score) if request.result_num > 0: scores = sq.fetch(limit=request.result_num) else: scores = sq.fetch() return ScoreForms(items=[score.to_score_form() for score in scores])
def get_user_scores(self, request): """Returns all of an individual User's scores""" user = User.query(User.user_name == request.user_name).get() if not user: raise endpoints.NotFoundException( 'A User with that name does not exist!') scores = Score.query(Score.user == user.key) if not scores: raise endpoints.NotFoundException("No scores found for this User") return ScoreForms(items=[score.to_form() for score in scores])
def get_user_scores(self, request): """Returns all of an individual User's scores""" user = User.query(User.name == request.user_name).get() if not user: raise endpoints.NotFoundException( 'A User with that name does not exist!') scores = Score.query(Score.user == user.key).fetch() if len(scores) > 0: return ScoreForms(items=[score.to_form() for score in scores]) else: raise endpoints.NotFoundException('No scores yet for this player!')
def get_user_scores(self, request): """ Returns all of an individual User's scores get and set rank/score info in memcache for fast retriving """ user = User.query(User.name == request.user_name).get() if not user: raise endpoints.NotFoundException( 'A User with that name does not exist!') scores = Score.query(Score.user == user.key) return ScoreForms(items=[score.to_form() for score in scores])
def get_user_scores(self, request): """Returns all of an individual User's scores""" user = User.query(User.name == request.user_name).get() if not user: raise endpoints.NotFoundException( 'A User with that name does not exist!') scores = Score.query(Score.user == user.key) if scores.get() is not None: return ScoreForms(scores=[score.to_form() for score in scores]) else: raise endpoints.NotFoundException( 'User has no scores at this time.')
def leader_board(self, request): """Return a leaderboard. A complete game with more tries_remaining ranks higher than a complete game with less tries remaining. A correct guess does not reduce tries_remaining.""" # Catch no games finished: scores = Score.query(Score.won == True).order(-Score.points) if not scores: raise endpoints.NotFoundException('No Games exist.') # Optionally limit results to passed in param. scores = scores.fetch(limit=request.number_of_results) return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """get_high_scores, filter by top 10 add request_message with optional number to results order by guess, descendng, and game_over = True""" ng = request.top_n_games print "number of games: ", ng high_scores = [ score.to_form() for score in Score.query( Score.won == True).order(Score.guesses).fetch(ng) ] return ScoreForms(items=high_scores)
def get_high_scores(self, request): """ Gets high scores in descending order, optionally with a (positive) limit on the number of results """ query = Score.query().order(-Score.score) if request.limit is not None: if request.limit <= 0: raise endpoints.BadRequestException('Limit must be positive') scores = query.fetch(request.limit) else: scores = query.fetch() return ScoreForms(items=[score.to_form() for score in scores])
def get_high_scores(self, request): """Returns a list of scores sorted by final_score in descending order""" try: count_of_results = int(request.number_of_results) if count_of_results == 0: scores = Score.query(Score.game_status == 'Won').order( -Score.final_score).fetch() else: scores = Score.query(Score.game_status == 'Won').order( -Score.final_score).fetch(limit=count_of_results) print scores return ScoreForms(items=[score.to_form() for score in scores]) except: raise endpoints.BadRequestException('Numbers only please...')