Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.timestamp = datetime.datetime.utcnow()
self.interaction = interaction
self.user = user
self.problem = problem
if event is not None and user is not None:
# There should always be an active user team, if not, throw an
# exception
# The current code works only if each user admins a single team.
if session is None:
self.event_team = EventTeam.query.filter_by(
event=event, team=user.admined_teams[0]).one_or_none()
else:
self.event_team = \
(session.query(EventTeam)
.filter(EventTeam.event == event)
.filter(EventTeam.team == user.admined_teams[0])
.one_or_none())
self.ip = ip
self.note = note
self.submission = submission
self.submission_file = submission_file
self.submission_file_diff = diff
self.submission_file_similarity = similarity
def __init__(self, interaction=None, user=None, problem=None, event=None,
ip=None, note=None, submission=None, submission_file=None,
diff=None, similarity=None, session=None):
self.timestamp = datetime.datetime.utcnow()
self.interaction = interaction
self.user = user
self.problem = problem
if event is not None and user is not None:
# There should always be an active user team, if not, throw an
# exception
# The current code works only if each user admins a single team.
if session is None:
self.event_team = EventTeam.query.filter_by(
event=event, team=user.admined_teams[0]).one_or_none()
else:
self.event_team = \
(session.query(EventTeam)
.filter(EventTeam.event == event)
.filter(EventTeam.team == user.admined_teams[0])
.one_or_none())
self.ip = ip
self.note = note
self.submission = submission
self.submission_file = submission_file
self.submission_file_diff = diff
self.submission_file_similarity = similarity
ip=None, note=None, submission=None, submission_file=None,
diff=None, similarity=None, session=None):
self.timestamp = datetime.datetime.utcnow()
self.interaction = interaction
self.user = user
self.problem = problem
if event is not None and user is not None:
# There should always be an active user team, if not, throw an
# exception
# The current code works only if each user admins a single team.
if session is None:
self.event_team = EventTeam.query.filter_by(
event=event, team=user.admined_teams[0]).one_or_none()
else:
self.event_team = \
(session.query(EventTeam)
.filter(EventTeam.event == event)
.filter(EventTeam.team == user.admined_teams[0])
.one_or_none())
self.ip = ip
self.note = note
self.submission = submission
self.submission_file = submission_file
self.submission_file_diff = diff
self.submission_file_similarity = similarity
The event name.
user_name : None or str, default is None
The user name. If None, scores from all users will be queried. This
parameter is discarded when requesting the competition leaderboard.
with_links : bool, default is True
Whether or not the submission name should be clickable.
Returns
-------
leaderboard : str
The leaderboard in HTML format.
"""
q = (session.query(Submission)
.filter(Event.id == EventTeam.event_id)
.filter(Team.id == EventTeam.team_id)
.filter(EventTeam.id == Submission.event_team_id)
.filter(Event.name == event_name))
if user_name is not None:
q = q.filter(Team.name == user_name)
submissions = q.all()
submission_filter = {'public': 'is_public_leaderboard',
'private': 'is_private_leaderboard',
'failed': 'is_error',
'new': 'is_new',
'public competition': 'is_in_competition',
'private competition': 'is_in_competition'}
submissions = [sub for sub in submissions
if (getattr(sub, submission_filter[leaderboard_type]) and
sub.is_not_sandbox)]
diff=None, similarity=None, session=None):
self.timestamp = datetime.datetime.utcnow()
self.interaction = interaction
self.user = user
self.problem = problem
if event is not None and user is not None:
# There should always be an active user team, if not, throw an
# exception
# The current code works only if each user admins a single team.
if session is None:
self.event_team = EventTeam.query.filter_by(
event=event, team=user.admined_teams[0]).one_or_none()
else:
self.event_team = \
(session.query(EventTeam)
.filter(EventTeam.event == event)
.filter(EventTeam.team == user.admined_teams[0])
.one_or_none())
self.ip = ip
self.note = note
self.submission = submission
self.submission_file = submission_file
self.submission_file_diff = diff
self.submission_file_similarity = similarity
The type of leaderboard to generate.
event_name : str
The event name.
user_name : None or str, default is None
The user name. If None, scores from all users will be queried. This
parameter is discarded when requesting the competition leaderboard.
with_links : bool, default is True
Whether or not the submission name should be clickable.
Returns
-------
leaderboard : str
The leaderboard in HTML format.
"""
q = (session.query(Submission)
.filter(Event.id == EventTeam.event_id)
.filter(Team.id == EventTeam.team_id)
.filter(EventTeam.id == Submission.event_team_id)
.filter(Event.name == event_name))
if user_name is not None:
q = q.filter(Team.name == user_name)
submissions = q.all()
submission_filter = {'public': 'is_public_leaderboard',
'private': 'is_private_leaderboard',
'failed': 'is_error',
'new': 'is_new',
'public competition': 'is_in_competition',
'private competition': 'is_in_competition'}
submissions = [sub for sub in submissions
if (getattr(sub, submission_filter[leaderboard_type]) and