<commit_before>from pprint import pprint

from utils.functions.models import dictlist
from utils.functions.queries import debug_cursor_execute

from lotes.functions.varias import modelo_de_ref


def query(
    cursor,
    fields='ref',
    ref=None,
    colecao=None,
    modelo=None,
    com_qtd_63=True,
):
    joins = set()

    if ref:
        if not isinstance(ref, (tuple, list)):
            ref = (ref, )
        ref_virgulas = ', '.join([f"'{r}'" for r in ref])
        filtra_ref = f"""--
            AND l.PROCONF_GRUPO in ({ref_virgulas})
        """
    else:
        filtra_ref = ''

    filtra_colecao = ''
    if colecao:
        filter_colecao = f"""
            AND r.COLECAO = '{colecao}'
        """
        joins.add('r')

    filtra_lote = """--
        AND l.CODIGO_ESTAGIO = 63
        AND l.QTDE_DISPONIVEL_BAIXA > 0
    """ if com_qtd_63 else """--
        AND l.SEQUENCIA_ESTAGIO = 1
    """

    fields_tuple = {
        'ref': ('ref', ),
        'inv': (
            'ref',
            'ordem_tam',
            'tam',
            'op',
            'oc',
            'per',
            'cor',
            'qtd',
        ),
        'emp': (
            'ref',<commit_msg>bug nome de variável<commit_after>from pprint import pprint

from utils.functions.models import dictlist
from utils.functions.queries import debug_cursor_execute

from lotes.functions.varias import modelo_de_ref


def query(
    cursor,
    fields='ref',
    ref=None,
    colecao=None,
    modelo=None,
    com_qtd_63=True,
):
    joins = set()

    if ref:
        if not isinstance(ref, (tuple, list)):
            ref = (ref, )
        ref_virgulas = ', '.join([f"'{r}'" for r in ref])
        filtra_ref = f"""--
            AND l.PROCONF_GRUPO in ({ref_virgulas})
        """
    else:
        filtra_ref = ''

    filtra_colecao = ''
    if colecao:
        filtra_colecao = f"""
            AND r.COLECAO = '{colecao}'
        """
        joins.add('r')

    filtra_lote = """--
        AND l.CODIGO_ESTAGIO = 63
        AND l.QTDE_DISPONIVEL_BAIXA > 0
    """ if com_qtd_63 else """--
        AND l.SEQUENCIA_ESTAGIO = 1
    """

    fields_tuple = {
        'ref': ('ref', ),
        'inv': (
            'ref',
            'ordem_tam',
            'tam',
            'op',
            'oc',
            'per',
            'cor',
            'qtd',
        ),
        'emp': (
            'ref',
{'fraction_non_alphanumeric': 0.138160632542655, 'fraction_numerical': 0.006658343736995423, 'mean_word_length': 1.5793991416309012, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1551714', 'n_tokens_mistral': 869, 'n_tokens_neox': 858, 'n_words': 172}