11from tqdm import tqdm
22from django .core .management .base import BaseCommand
33from django .db import transaction
4+ import django .utils .timezone as timezone
45
56from courses .models import Course , Section
67from courses .models import course_reviews , sections_with_reviews
@@ -29,7 +30,6 @@ def handle(self, *args, **options):
2930 self .stdout .write (self .style .SUCCESS ("Finished calculating Section review averages." ))
3031
3132 def update_courses (self ):
32- print ("Starting this lol" )
3333 queryset = course_reviews (
3434 Course .objects .all (),
3535 prefix = PREFIX ,
@@ -40,6 +40,7 @@ def update_courses(self):
4040 for course in tqdm (queryset , desc = "Updating Courses" , file = self .stdout ):
4141 for field in REVIEW_FIELDS :
4242 setattr (course , field , getattr (course , PREFIX + field ))
43+ course .annotation_expiration = timezone .now + timezone .timedelta (days = 30 )
4344 courses_to_update .append (course )
4445
4546 with transaction .atomic ():
@@ -60,6 +61,7 @@ def update_sections(self):
6061 for section in tqdm (queryset , desc = "Updating Sections" , file = self .stdout ):
6162 for field in REVIEW_FIELDS :
6263 setattr (section , field , getattr (section , PREFIX + field ))
64+ section .annotation_expiration = timezone .now + timezone .timedelta (days = 30 )
6365 sections_to_update .append (section )
6466
6567 with transaction .atomic ():
0 commit comments