<commit_before># -*- coding: utf-8 -*-
import fdc
import commons_cat_metrics

# Output template
template_photo = """
{{Suivi FDC/En-tête}}
{{Suivi FDC/Groupe|groupe=Soutien aux photographes}}
{{Suivi FDC/Indicateur|indicateur=Nombre de fichiers mis en ligne|q1= ${nb_q1} |q2= ${nb_q2} |q3= ${nb_q3} |q4= ${nb_q4} |cumul= ${nb_value}|Objectif=9000}}
{{Suivi FDC/Indicateur|indicateur=% de fichiers mis en ligne et ayant reçu un label|q1=${featured_q1}|q2=${featured_q2}|q3=${featured_q3}|q4=${featured_q4}|cumul=${featured_value}|Objectif=5%}}
{{Suivi FDC/Fin}}
"""


def make_example_report(fdc_round, category):
    """Quick report maker"""
    # Quick and dirty metrics object
    quarters = [commons_cat_metrics.CommonsCatMetrics(category, fdc_round, i+1) for i in range(4)]

    # retrieving values from metrics object
    files = [quarters[i].get_nb_files() for i in range(4)]
    labels = [100*float(quarters[i].get_nb_featured_files())/float(files[i]) for i in range(4)]

    # Creating reporting
    nb_file = fdc.Indicator("nb", q1=files[0], q2=files[1], q3=files[2], q4=files[3], value=files[0]+files[1]+files[2]+files[3])
    pct_labels = fdc.Indicator("featured",
                               q1=round(labels[0], 2), q2=round(labels[1], 2),
                               q3=round(labels[2], 2), q4=round(labels[3], 2),<commit_msg>clean up code in order to use only one SQL connection<commit_after># -*- coding: utf-8 -*-
import fdc
import commons_cat_metrics

# Output template
template_photo = """
{{Suivi FDC/En-tête}}
{{Suivi FDC/Groupe|groupe=Soutien aux photographes}}
{{Suivi FDC/Indicateur|indicateur=Nombre de fichiers mis en ligne|q1= ${nb_q1} |q2= ${nb_q2} |q3= ${nb_q3} |q4= ${nb_q4} |cumul= ${nb_value}|Objectif=9000}}
{{Suivi FDC/Indicateur|indicateur=% de fichiers mis en ligne et ayant reçu un label|q1=${featured_q1}|q2=${featured_q2}|q3=${featured_q3}|q4=${featured_q4}|cumul=${featured_value}|Objectif=5%}}
{{Suivi FDC/Fin}}
"""


def make_example_report(fdc_round, category):
    """Quick report maker"""
    # Quick and dirty metrics object
    db = commons_cat_metrics.get_commons_db()
    quarters = [commons_cat_metrics.CommonsCatMetrics(category, fdc_round, i+1, database=db) for i in range(4)]

    # retrieving values from metrics object
    files = [quarters[i].get_nb_files() for i in range(4)]
    labels = [100*float(quarters[i].get_nb_featured_files())/float(files[i]) for i in range(4)]
    db.close()

    # Creating reporting
    nb_file = fdc.Indicator("nb", q1=files[0], q2=files[1], q3=files[2], q4=files[3], value=files[0]+files[1]+files[2]+files[3])
    pct_labels = fdc.Indicator("featured",
                               q1=round(labels[0], 2), q2=round(labels[1], 2),
                               q3=round(labels[2], 2), q4=round(labels[3], 2),
{'fraction_non_alphanumeric': 0.1665477888730385, 'fraction_numerical': 0.037803138373751786, 'mean_word_length': 4.678137651821863, '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': '4098425', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1049, 'n_words': 215}