예제 #1
0
def setup_analytics():
    sys.stdout.write("create_contentslices\n")
    ContentSlice.create_slices()
    sys.stdout.write("create_cohorts\n")
    Cohort.create_cohorts()
    sys.stdout.write("create_slices\n")
    Cohort.create_slices()
    sys.stdout.write("create_devices\n")
    AnalyticsDevice.create_devices()
    sys.stdout.write("processing devices\n")
    for device_id in AnalyticsDevice.objects.values_list("device_id", flat=True):
        if settings.IS_PRODUCTION or settings.IS_CANNON:
            process_device_analytics.apply_async(
                (device_id,),
                retry=True,
                retry_policy={"max_retries": 10, "interval_start": 5.0, "interval_step": 5.0, "interval_max": 60.0},
            )
        else:
            process_device_analytics(device_id)
    sys.stdout.write("processing content\n")
    # for content_slice in ContentSlice.objects.all():
    for content_slice in ContentSlice.objects.filter(complete=False):
        if settings.IS_PRODUCTION:
            aggregate_content_analytics.apply_async(
                (content_slice,),
                retry=True,
                retry_policy={"max_retries": 10, "interval_start": 5.0, "interval_step": 5.0, "interval_max": 60.0},
            )
        else:
            aggregate_content_analytics(content_slice)
예제 #2
0
def content(request):
    response = HttpResponse(content_type="text/csv")
    response["Content-Disposition"] = "attachment; filename=%s.csv" % "content"
    writer = csv.writer(response)
    ContentSlice.create_report(writer)
    return response