figures/tasks.py
def experimental_populate_daily_metrics(date_for=None, force_update=False):
    '''Experimental task to populate daily metrics

    WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of
    processing course metrics. Not all the courses get processed and the site
    metrics doesn't get called.

    We're keeping it in the tasks so that we can continue to debug this.
    Enabling parallel course tasks will improve the pipeline performance

    '''
    def include_course(course_overview, threshold=50):
        '''This function let's us skip over courses with many enrollments, speeding
        up testing. Do not use for production
        '''
        count = CourseEnrollment.objects.filter(course_id=course_overview.id).count()
        return False if count > threshold else True

    if date_for:
        date_for = as_date(date_for)
    else:
        date_for = datetime.datetime.utcnow().replace(tzinfo=utc).date()
    date_for = date_for.strftime("%Y-%m-%d")
    logger.info(
        'Starting task "figures.experimental_populate_daily_metrics" for date "{}"'.format(
            date_for))

    courses = CourseOverview.objects.all()
    cdm_tasks = [
        populate_single_cdm.s(
            course_id=six.text_type(course.id),  # noqa: F821
            date_for=date_for,
            force_update=force_update) for course in courses if include_course(course)
    ]
    results = chord(cdm_tasks)(populate_site_daily_metrics.s(
        date_for=date_for, force_update=force_update))

    # TODO: Are we going to update the SDM for the day if
    # * course records were created, meaning there are data not added to the SDM
    # * the SDM record already exists
    # * force_update is not true

    logger.info(
        'Finished task "figures.experimental_populate_daily_metrics" for date "{}"'.format(
            date_for))

    return results
Experimental task to populate daily metrics

    WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of
    processing course metrics. Not all the courses get processed and the site
    metrics doesn't get called.

    We're keeping it in the tasks so that we can continue to debug this.
    Enabling parallel course tasks will improve the pipeline performance

    
Experimental task to populate daily metrics
WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of
processing course metrics. Not all the courses get processed and the site
metrics doesn't get called.

We're keeping it in the tasks so that we can continue to debug this.
Enabling parallel course tasks will improve the pipeline performance
Experimental task to populate daily metrics WARNING : In Ginkgo devstack this task tends to gets stuck in the middle of processing course metrics . Not all the courses get processed and the site metrics doesn ' t get called . We ' re keeping it in the tasks so that we can continue to debug this . Enabling parallel course tasks will improve the pipeline performance
def experimental_populate_daily_metrics(date_for=None, force_update=False):
    def include_course(course_overview, threshold=50):
        count = CourseEnrollment.objects.filter(course_id=course_overview.id).count()
        return False if count > threshold else True
    if date_for:
        date_for = as_date(date_for)
    else:
        date_for = datetime.datetime.utcnow().replace(tzinfo=utc).date()
    date_for = date_for.strftime("%Y-%m-%d")
    logger.info(
        'Starting task "figures.experimental_populate_daily_metrics" for date "{}"'.format(
            date_for))
    courses = CourseOverview.objects.all()
    cdm_tasks = [
        populate_single_cdm.s(
            course_id=six.text_type(course.id),  
            date_for=date_for,
            force_update=force_update) for course in courses if include_course(course)
    ]
    results = chord(cdm_tasks)(populate_site_daily_metrics.s(
        date_for=date_for, force_update=force_update))
    logger.info(
        'Finished task "figures.experimental_populate_daily_metrics" for date "{}"'.format(
            date_for))
    return results
def experimental_populate_daily_metrics ( date_for = None , force_update = False ) : def include_course ( course_overview , threshold = 50 ) : '''This function let's us skip over courses with many enrollments, speeding
        up testing. Do not use for production
        ''' count = CourseEnrollment . objects . filter ( course_id = course_overview . id ) . count ( ) return False if count > threshold else True if date_for : date_for = as_date ( date_for ) else : date_for = datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) . date ( ) date_for = date_for . strftime ( "%Y-%m-%d" ) logger . info ( 'Starting task "figures.experimental_populate_daily_metrics" for date "{}"' . format ( date_for ) ) courses = CourseOverview . objects . all ( ) cdm_tasks = [ populate_single_cdm . s ( course_id = six . text_type ( course . id ) , date_for = date_for , force_update = force_update ) for course in courses if include_course ( course ) ] results = chord ( cdm_tasks ) ( populate_site_daily_metrics . s ( date_for = date_for , force_update = force_update ) ) logger . info ( 'Finished task "figures.experimental_populate_daily_metrics" for date "{}"' . format ( date_for ) ) return results
Experimental task to populate daily metrics
WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of
processing course metrics.
Experimental task to populate daily metrics WARNING : In Ginkgo devstack this task tends to gets stuck in the middle of processing course metrics .
'''Experimental task to populate daily metrics

    WARNING: In Ginkgo devstack, this task tends to gets stuck in the middle of
    processing course metrics. Not all the courses get processed and the site
    metrics doesn't get called.

    We're keeping it in the tasks so that we can continue to debug this.
    Enabling parallel course tasks will improve the pipeline performance

    ''' '''This function let's us skip over courses with many enrollments, speeding
        up testing. Do not use for production
        ''' # noqa: F821 # TODO: Are we going to update the SDM for the day if # * course records were created, meaning there are data not added to the SDM # * the SDM record already exists # * force_update is not true
date_for
force_update