<commit_before>from celery import shared_task
from .typeform import sync_facilitator_responses
from .typeform import sync_learner_responses
from .community_feedback import calculate_course_ratings
from .community_feedback import calculate_course_tagdorsements

@shared_task
def sync_surveys():
    new_facilitator_responses = sync_facilitator_responses()
    new_learner_responses = sync_learner_responses()
    affected_courses = set([r.study_group.course for r in new_facilitator_responses + new_learner_responses if r.study_group and r.study_group.course])
    for courses in affected_courses:
        calculate_course_ratings(course)
        calculate_course_tagdorsements(course)<commit_msg>Fix error when updating course info after a survey has been filled out. See #503<commit_after>from celery import shared_task
from .typeform import sync_facilitator_responses
from .typeform import sync_learner_responses
from .community_feedback import calculate_course_ratings
from .community_feedback import calculate_course_tagdorsements

@shared_task
def sync_surveys():
    new_facilitator_responses = sync_facilitator_responses()
    new_learner_responses = sync_learner_responses()
    affected_courses = set([r.study_group.course for r in new_facilitator_responses + new_learner_responses if r.study_group and r.study_group.course])
    for course in affected_courses:
        calculate_course_ratings(course)
        calculate_course_tagdorsements(course)
{'fraction_non_alphanumeric': 0.04663923182441701, 'fraction_numerical': 0.00205761316872428, 'mean_word_length': 6.520618556701031, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3989273', 'n_tokens_mistral': 453, 'n_tokens_neox': 429, 'n_words': 101}