<s> """<STR_LIT>""" <EOL> from datetime import datetime , timedelta <EOL> from django . utils . timezone import utc <EOL> from django . db import models <EOL> from django . contrib . auth . models import User <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . contrib . contenttypes import generic <EOL> from . algorithm import interval <EOL> class Practice ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> content_type = models . ForeignKey ( ContentType ) <EOL> object_id = models . PositiveIntegerField ( ) <EOL> item = generic . GenericForeignKey ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> started_last_viewing = models . DateTimeField ( null = True , blank = True , auto_now_add = True ) <EOL> ended_last_viewing = models . DateTimeField ( null = True , blank = True , auto_now_add = True ) <EOL> user = models . ForeignKey ( User ) <EOL> next_practice = models . DateTimeField ( auto_now_add = True ) <EOL> times_practiced = models . PositiveIntegerField ( default = <NUM_LIT:0> ) <EOL> easy_factor = models . FloatField ( default = <NUM_LIT> ) <EOL> class Meta : <EOL> ordering = [ '<STR_LIT>' ] <EOL> def set_next_practice ( self , rating ) : <EOL> """<STR_LIT>""" <EOL> self . times_practiced += <NUM_LIT:1> <EOL> minutes , ef = interval ( self . times_practiced , rating , self . easy_factor ) <EOL> self . next_practice = datetime . utcnow ( ) . replace ( tzinfo = utc ) + timedelta ( minutes = minutes ) <EOL> self . easy_factor = ef <EOL> def delay ( self ) : <EOL> """<STR_LIT>""" <EOL> self . next_practice = datetime . utcnow ( ) . replace ( tzinfo = utc ) + timedelta ( minutes = <NUM_LIT:10> ) </s>
