from django.http import JsonResponse
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
from .models import BalancingAuthority, GenerationMix
from .serializers import GenerationMixSerializer


def index(request):
    return render(request, 'caiso/index.html')


@csrf_exempt
def yesterdays_mixes(request):
    ba = BalancingAuthority.objects.get(name='CAISO')
    gms = GenerationMix.objects.filter(balancing_authority=ba).order_by('-id')[
        :24]
    gms = sorted(gms, key=lambda gm: gm.timestamp)
    serialized_gms = []
    for gm in gms:
        serialized_gms.append(GenerationMixSerializer(gm).data())
    return JsonResponse({'generation_mixes': serialized_gms})

bd6a298800604dad7fef041a1c20277f4e708420
<mask token>

<mask token>


@csrf_exempt
def yesterdays_mixes(request):
    ba = BalancingAuthority.objects.get(name='CAISO')
    gms = GenerationMix.objects.filter(balancing_authority=ba).order_by('-id')[
        :24]
    gms = sorted(gms, key=lambda gm: gm.timestamp)
    serialized_gms = []
    for gm in gms:
        serialized_gms.append(GenerationMixSerializer(gm).data())
    return JsonResponse({'generation_mixes': serialized_gms})

<mask token>


def index(request):
    return render(request, 'caiso/index.html')


@csrf_exempt
def yesterdays_mixes(request):
    ba = BalancingAuthority.objects.get(name='CAISO')
    gms = GenerationMix.objects.filter(balancing_authority=ba).order_by('-id')[
        :24]
    gms = sorted(gms, key=lambda gm: gm.timestamp)
    serialized_gms = []
    for gm in gms:
        serialized_gms.append(GenerationMixSerializer(gm).data())
    return JsonResponse({'generation_mixes': serialized_gms})

from django.http import JsonResponse
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
from .models import BalancingAuthority, GenerationMix
from .serializers import GenerationMixSerializer


def index(request):
    return render(request, 'caiso/index.html')


@csrf_exempt
def yesterdays_mixes(request):
    ba = BalancingAuthority.objects.get(name='CAISO')
    gms = GenerationMix.objects.filter(balancing_authority=ba).order_by('-id')[
        :24]
    gms = sorted(gms, key=lambda gm: gm.timestamp)
    serialized_gms = []
    for gm in gms:
        serialized_gms.append(GenerationMixSerializer(gm).data())
    return JsonResponse({'generation_mixes': serialized_gms})
