<commit_before># -*- coding: utf-8 -*-

from django.db.models import Sum
from django.db.models.expressions import RawSQL

from .utils import get_month


def filter_daily_total(queryset, context, qualif=False):
    if 'ano' in context and context['ano']:
        queryset = queryset.filter(
            ano=int(context['ano'])
        )

    if 'mes' in context and context['mes'] and not qualif:
        queryset = queryset.filter(
            mes=get_month(int(context['mes']))
        )
    elif 'mes' in context and context['mes'] and qualif:
        queryset = queryset.filter(
            mes=int(context['mes'])
        )

    if 'estagio' in context and context['estagio'] and context['tipo'] == 'AWIFS':
        queryset = queryset.filter(
            estagio=context['estagio']
        )

    if 'uf' in context and context['uf'] and not qualif:
        queryset = queryset.filter(
            estado=context['uf']
        )

    if not qualif: 
        return queryset.values('data_imagem')\
            .annotate(
                total=Sum('area_km2'),
            ).annotate(
                dia=RawSQL("EXTRACT(day FROM data_imagem)", ())
            )
    # else:
    #     if context['estagio'] == 'degradacao':
    #         return queryset.values('mes_ano')\
    #             .annotate(
    #                 total=Sum('degradacao_deter'),
    #             )
    #     elif context['estagio'] == 'corte':
    #         return queryset.values('mes_ano')\
    #             .annotate(
    #                 total=Sum('corte_raso_deter'),
    #             )
    #     elif context['estagio'] == 'cicatriz':
    #         return queryset.values('mes_ano')\
    #             .annotate(
    #                 total=Sum('cicatriz_fogo'),
    #             )


def filter_montly_total(queryset, context, qualif=False):
    if 'estagio' in context and context['estagio'] and not qualif:
        queryset = queryset.filter(
            estagio=context['estagio']
        )

    if 'uf' in context and context['uf'] and not qualif:
        queryset = queryset.filter(
            estado=context['uf']
        )

    if not qualif: 
        return queryset.extra(select={'mes_id': 'select EXTRACT(month from data_imagem)'}).values('mes_id')\<commit_msg>adding filtering for the return of graph 1<commit_after># -*- coding: utf-8 -*-

from django.db.models import Sum
from django.db.models.expressions import RawSQL

from .utils import get_month


def filter_daily_total(queryset, context, qualif=False):
    if 'ano' in context and context['ano']:
        queryset = queryset.filter(
            ano=int(context['ano'])
        )

    if 'mes' in context and context['mes'] and not qualif:
        queryset = queryset.filter(
            mes=get_month(int(context['mes']))
        )
    elif 'mes' in context and context['mes'] and qualif:
        queryset = queryset.filter(
            mes=int(context['mes'])
        )

    if 'estagio' in context and context['estagio'] and context['tipo'] == 'AWIFS':
        queryset = queryset.filter(
            estagio=context['estagio']
        )

    if 'uf' in context and context['uf'] and not qualif:
        queryset = queryset.filter(
            estado=context['uf']
        )

    if not qualif: 
        return queryset.values('data_imagem')\
            .annotate(
                total=Sum('area_km2'),
            ).annotate(
                dia=RawSQL("EXTRACT(day FROM data_imagem)", ())
            ).order_by('dia')
    # else:
    #     if context['estagio'] == 'degradacao':
    #         return queryset.values('mes_ano')\
    #             .annotate(
    #                 total=Sum('degradacao_deter'),
    #             )
    #     elif context['estagio'] == 'corte':
    #         return queryset.values('mes_ano')\
    #             .annotate(
    #                 total=Sum('corte_raso_deter'),
    #             )
    #     elif context['estagio'] == 'cicatriz':
    #         return queryset.values('mes_ano')\
    #             .annotate(
    #                 total=Sum('cicatriz_fogo'),
    #             )


def filter_montly_total(queryset, context, qualif=False):
    if 'estagio' in context and context['estagio'] and not qualif:
        queryset = queryset.filter(
            estagio=context['estagio']
        )

    if 'uf' in context and context['uf'] and not qualif:
        queryset = queryset.filter(
            estado=context['uf']
        )

    if not qualif: 
        return queryset.extra(select={'mes_id': 'select EXTRACT(month from data_imagem)'}).values('mes_id')\
{'fraction_non_alphanumeric': 0.13066316480630336, 'fraction_numerical': 0.001094331363536879, 'mean_word_length': 1.954104718810601, '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': '6858563', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1385, 'n_words': 297}