Exemplo n.º 1
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)
Exemplo n.º 2
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)