示例#1
0
    def add_new_exercise_result(self, exercise_source: ExerciseSource,
                                exercise_outcome: ExerciseOutcome,
                                exercise_solving_speed):

        exercise = Exercise(exercise_outcome, exercise_source,
                            exercise_solving_speed, datetime.now())

        self.add_new_exercise(exercise)
        db.session.add(exercise)

        return exercise
示例#2
0
    def _create_model_object(self):
        random_outcome = OutcomeRule().random
        random_source = SourceRule().random
        random_speed = random.randint(500, 5000)
        random_time = self.faker.date_time_this_month()

        new_exercise = Exercise(random_outcome, random_source, random_speed,
                                random_time)

        if self._exists_in_db(new_exercise):
            return self._create_model_object()

        return new_exercise
示例#3
0
    def add_new_exercise_result(self, exercise_source, exercise_outcome,
                                exercise_solving_speed):

        from .user_exercise_session import UserExerciseSession

        new_source = ExerciseSource.query.filter_by(
            source=exercise_source.source).first()
        new_outcome = ExerciseOutcome.query.filter_by(
            outcome=exercise_outcome.outcome).first()
        exercise = Exercise(new_outcome, new_source, exercise_solving_speed,
                            datetime.now())
        self.add_new_exercise(exercise)
        db.session.add(exercise)
示例#4
0
    def setUp(self):
        super().setUp()
        exercise_session_rule = ExerciseSessionRule()
        self.ex_session1 = exercise_session_rule.exercise_session
        self.user = exercise_session_rule.user
        self.bookmark = exercise_session_rule.bookmark
        self.exercises = Exercise.find(user_id=self.user.id)

        self.exercise_session_timeout = UserExerciseSession.get_exercise_session_timeout(
        )
        self.VERY_FAR_IN_THE_PAST = '2000-01-01T00:00:00'
        self.VERY_FAR_IN_THE_FUTURE = '2030-01-01T00:00:00'
        self.CURRENT_TIME = datetime.now()
        self.TIMEOUT_SECONDS_IN_THE_PAST = datetime.now() - timedelta(
            seconds=self.exercise_session_timeout)
        self.SOME_TIME_AGO = datetime.now() - timedelta(
            seconds=self.exercise_session_timeout * 20)
        self.A_BIT_LATER_THAN_SOME_TIME_AGO = datetime.now() - timedelta(
            seconds=self.exercise_session_timeout * 30)
示例#5
0
from zeeguu_core.model.exercise import Exercise
from zeeguu_core.model.user_exercise_session import UserExerciseSession

import zeeguu_core
'''
    Script that loops through all the exercises in the database, and recomputes the history of
    exercise sessions. 

    NOTE: It clears and recreates the table
'''

db_session = zeeguu_core.db.session

#Clear table before starting
UserExerciseSession.query.delete()
db_session.commit()

data = Exercise.find()

for user_exercise in data:

    #Skip misleading records
    if user_exercise.solving_speed < 2147483647 and user_exercise.solving_speed > 0:

        UserExerciseSession.update_exercise_session(user_exercise, db_session)
        print(user_exercise.id)