How to use the ramp-database.ramp_database.model.event.EventTeam function in ramp-database

To help you get started, we’ve selected a few ramp-database examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paris-saclay-cds / ramp-board / ramp-database / ramp_database / model / user.py View on Github external
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
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / model / user.py View on Github external
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
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / model / user.py View on Github external
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
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / leaderboard.py View on Github external
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)]
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / model / user.py View on Github external
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
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / leaderboard.py View on Github external
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