backend/model_api/views.py
def cumulative_infections(request):
    """
    This endpoint returns the number of cumulative infections for each area to
    date.
    """
    #total = sum([d.data_point.val for d in Covid19CumulativeDataPoint.objects.all()])
    greatest_model = Covid19Model.objects.get(name="SI-kJalpha - 40x")
    greatest_predictions = Covid19PredictionDataPoint.objects.filter(model=greatest_model)
    greatest_predictions = greatest_predictions.filter(date=greatest_predictions.last().date, social_distancing=1)
    greatest_vals = [d.val for d in greatest_predictions]
    max_val = max(greatest_vals)
    response = [{
        'area': {
            'country': d.area.country,
            'state': d.area.state,
            'iso_2': d.area.iso_2,
        },
        'value': d.data_point.val,
        #'norm': 1e7*((d.data_point.val - mean)/var - min_norm),
        #'percentage': 1e3*d.data_point.val/total,
        'max_percentage': 1e4*d.data_point.val/max_val,
        'date': d.data_point.date,
    } for d in Covid19CumulativeDataPoint.objects.all()]

    #experiment to check for infection number's distribution
    # values = [1e4*d/max_val for d in greatest_vals]
    # values.sort()
    # print(values)
    # marks = []
    # for i in range(0, 240, 10):
    #     marks.append(values[i])
    # print(marks)
    return Response(response)

    This endpoint returns the number of cumulative infections for each area to
    date.
    
This endpoint returns the number of cumulative infections for each area to
date.
This endpoint returns the number of cumulative infections for each area to date .
def cumulative_infections(request):
    greatest_model = Covid19Model.objects.get(name="SI-kJalpha - 40x")
    greatest_predictions = Covid19PredictionDataPoint.objects.filter(model=greatest_model)
    greatest_predictions = greatest_predictions.filter(date=greatest_predictions.last().date, social_distancing=1)
    greatest_vals = [d.val for d in greatest_predictions]
    max_val = max(greatest_vals)
    response = [{
        'area': {
            'country': d.area.country,
            'state': d.area.state,
            'iso_2': d.area.iso_2,
        },
        'value': d.data_point.val,
        'max_percentage': 1e4*d.data_point.val/max_val,
        'date': d.data_point.date,
    } for d in Covid19CumulativeDataPoint.objects.all()]
    return Response(response)
def cumulative_infections ( request ) : greatest_model = Covid19Model . objects . get ( name = "SI-kJalpha - 40x" ) greatest_predictions = Covid19PredictionDataPoint . objects . filter ( model = greatest_model ) greatest_predictions = greatest_predictions . filter ( date = greatest_predictions . last ( ) . date , social_distancing = 1 ) greatest_vals = [ d . val for d in greatest_predictions ] max_val = max ( greatest_vals ) response = [ { 'area' : { 'country' : d . area . country , 'state' : d . area . state , 'iso_2' : d . area . iso_2 , } , 'value' : d . data_point . val , 'max_percentage' : 1e4 * d . data_point . val / max_val , 'date' : d . data_point . date , } for d in Covid19CumulativeDataPoint . objects . all ( ) ] return Response ( response )
This endpoint returns the number of cumulative infections for each area to
date.
This endpoint returns the number of cumulative infections for each area to date .
"""
    This endpoint returns the number of cumulative infections for each area to
    date.
    """ #total = sum([d.data_point.val for d in Covid19CumulativeDataPoint.objects.all()]) #'norm': 1e7*((d.data_point.val - mean)/var - min_norm), #'percentage': 1e3*d.data_point.val/total, #experiment to check for infection number's distribution # values = [1e4*d/max_val for d in greatest_vals] # values.sort() # print(values) # marks = [] # for i in range(0, 240, 10): #     marks.append(values[i]) # print(marks)
request