def unlock_all_questions(age_minutes: int = None): if age_minutes is None: unlocked = Question.update({ Question.locked_by: None, Question.locked_at: None }).execute() logger.info("%i old questions have been unlocked", unlocked) else: age_moment = sub_timedelta(timedelta(minutes=age_minutes)) unlocked = (Question.update({ Question.locked_by: None, Question.locked_at: None }).where(Question.locked_at < age_moment)).execute() logger.info("%i old questions (max age: %i) have been unlocked", unlocked, age_minutes)
def get_test_scan_timeout_moment(cls) -> datetime: """Returns datetime a moment of the timeout gone""" return sub_timedelta(timedelta(seconds=cls.TEST_SCAN_INTERVAL))
def get_account_reserve_out_moment(cls) -> datetime: """Returns datetime which contains a moment of the account timeout""" return sub_timedelta(timedelta(minutes=cls.ACCOUNT_RESERVE_TIMEOUT))
def get_course_scan_timeout_moment(cls) -> datetime: """Returns datetime which contains a moment of the course update timeout""" return sub_timedelta(timedelta(minutes=cls.COURSE_SCAN_INTERVAL))
def get_account_aging_moment(cls) -> datetime: """Returns datetime which contains a moment of the account aging""" return sub_timedelta(timedelta(minutes=cls.MAX_ACCOUNT_AGE))