mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 14:34:21 +01:00
Add a raw_query parameter to the standings functions
This commit is contained in:
@@ -8,7 +8,7 @@ from CTFd.utils.modes import get_model
|
||||
|
||||
|
||||
@cache.memoize(timeout=60)
|
||||
def get_standings(count=None, admin=False, fields=[]):
|
||||
def get_standings(count=None, admin=False, fields=[], raw_query=False):
|
||||
"""
|
||||
Get standings as a list of tuples containing account_id, name, and score e.g. [(account_id, team_name, score)].
|
||||
|
||||
@@ -108,16 +108,20 @@ def get_standings(count=None, admin=False, fields=[]):
|
||||
"""
|
||||
Only select a certain amount of users if asked.
|
||||
"""
|
||||
if count is None:
|
||||
standings = standings_query.all()
|
||||
else:
|
||||
standings = standings_query.limit(count).all()
|
||||
if count:
|
||||
standings = standings_query.limit(count)
|
||||
|
||||
return standings
|
||||
"""
|
||||
Return the raw query if requested
|
||||
"""
|
||||
if raw_query:
|
||||
return standings
|
||||
|
||||
return standings.all()
|
||||
|
||||
|
||||
@cache.memoize(timeout=60)
|
||||
def get_team_standings(count=None, admin=False, fields=[]):
|
||||
def get_team_standings(count=None, admin=False, fields=[], raw_query=False):
|
||||
scores = (
|
||||
db.session.query(
|
||||
Solves.team_id.label("team_id"),
|
||||
@@ -188,16 +192,17 @@ def get_team_standings(count=None, admin=False, fields=[]):
|
||||
.order_by(sumscores.columns.score.desc(), sumscores.columns.id)
|
||||
)
|
||||
|
||||
if count is None:
|
||||
standings = standings_query.all()
|
||||
else:
|
||||
standings = standings_query.limit(count).all()
|
||||
if count:
|
||||
standings = standings_query.limit(count)
|
||||
|
||||
return standings
|
||||
if raw_query:
|
||||
return standings
|
||||
|
||||
return standings.all()
|
||||
|
||||
|
||||
@cache.memoize(timeout=60)
|
||||
def get_user_standings(count=None, admin=False, fields=[]):
|
||||
def get_user_standings(count=None, admin=False, fields=[], raw_query=False):
|
||||
scores = (
|
||||
db.session.query(
|
||||
Solves.user_id.label("user_id"),
|
||||
@@ -267,9 +272,10 @@ def get_user_standings(count=None, admin=False, fields=[]):
|
||||
.order_by(sumscores.columns.score.desc(), sumscores.columns.id)
|
||||
)
|
||||
|
||||
if count is None:
|
||||
standings = standings_query.all()
|
||||
else:
|
||||
standings = standings_query.limit(count).all()
|
||||
if count:
|
||||
standings = standings_query.limit(count)
|
||||
|
||||
return standings
|
||||
if raw_query:
|
||||
return standings
|
||||
|
||||
return standings.all()
|
||||
|
||||
Reference in New Issue
Block a user