コード例 #1
0
 def test_get_number_solved_subquery(self):
     c = self.make_challenge()
     t = self.make_team()
     s = Submission(challenge=c, team=t)
     self.dbsession.add(s)
     q = (self.dbsession.query(Challenge, get_number_solved_subquery()))
     chall, count = q.first()
     assert c is chall
     assert count == 1
コード例 #2
0
ファイル: front.py プロジェクト: Immortalem/fluxscoreboard
 def challenges(self):
     """
     A list of all challenges similar to the scoreboard view in a table.
     It has a very complex query that gets all challennges together with
     a boolean of whether the current team has solved it, and the number
     of times this challenge was solved overall. This list of tuples
     ``(challenge, team_solved, number_solved_total)`` is then given to the
     template and rendered.
     """
     team_id = self.request.authenticated_userid
     team_solved_subquery = get_team_solved_subquery(team_id)
     number_of_solved_subquery = get_number_solved_subquery()
     challenges = (DBSession.query(
         Challenge, team_solved_subquery, number_of_solved_subquery).
         options(joinedload("category")).
         filter(Challenge.published).
         order_by(Challenge.id))
     return {'challenges': challenges}