@cronjobs.register
def reindex_users_that_contributed_yesterday():
 if settings.STAGE:
  return
 today = datetime.now()
 yesterday = (today - timedelta(days=1))
 user_ids = list(Answer.objects.filter(created__gte=yesterday, created__lt=today).values_list('creator_id', flat=True))
 user_ids += list(Revision.objects.filter(created__gte=yesterday, created__lt=today).values_list('creator_id', flat=True))
 user_ids += list(Revision.objects.filter(reviewed__gte=yesterday, reviewed__lt=today).values_list('reviewer_id', flat=True))
 index_task.delay(UserMappingType, list(set(user_ids)))

@ cronjobs . register def reindex_users_that_contributed_yesterday ( ) : if settings . STAGE : return today = datetime . now ( ) yesterday = ( today - timedelta ( days = 1 ) ) user_ids = list ( Answer . objects . filter ( created__gte = yesterday , created__lt = today ) . values_list ( 'creator_id' , flat = True ) ) user_ids += list ( Revision . objects . filter ( created__gte = yesterday , created__lt = today ) . values_list ( 'creator_id' , flat = True ) ) user_ids += list ( Revision . objects . filter ( reviewed__gte = yesterday , reviewed__lt = today ) . values_list ( 'reviewer_id' , flat = True ) ) index_task . delay ( UserMappingType , list ( set ( user_ids ) ) )
update the users that contributed yesterday .