<commit_before>"""Graph facilities for the Analytics study view."""
import datetime
from functools import reduce

import altair
import pandas
import panel
from django_pandas.io import read_frame


altair.renderers.enable("default")
panel.extension("vega")
pandas.set_option("display.max_columns", None)
pandas.set_option("display.max_rows", None)


def _get_base_responses_dataframe(responses_queryset):
    response_dataframe = read_frame(
        responses_queryset,
        fieldnames=("date_created", "current_ruling", "study__name", "study__id"),
        index_col="uuid",
    )

    return response_dataframe


def get_response_timeseries_data(responses_queryset):
    """This method has one job, and that's to package data for MetricsGraphics.JS.

    Format:
        [
            {
                "timestamp": [UTC timestamp],
                "count_per_study": [The count for each study]
                "count_per_ruling": [the count per ruling]
                "count_per_study_by_ruling: [the count per study and ruling]
            }
        ]

    The idea here is to have the grouped counts easily accessible to javascript, such that the<commit_msg>Fixing broken build - getting rid of panel<commit_after>"""Graph facilities for the Analytics study view."""
import datetime
from functools import reduce

import altair
import pandas
from django_pandas.io import read_frame


altair.renderers.enable("default")
pandas.set_option("display.max_columns", None)
pandas.set_option("display.max_rows", None)


def _get_base_responses_dataframe(responses_queryset):
    response_dataframe = read_frame(
        responses_queryset,
        fieldnames=("date_created", "current_ruling", "study__name", "study__id"),
        index_col="uuid",
    )

    return response_dataframe


def get_response_timeseries_data(responses_queryset):
    """This method has one job, and that's to package data for MetricsGraphics.JS.

    Format:
        [
            {
                "timestamp": [UTC timestamp],
                "count_per_study": [The count for each study]
                "count_per_ruling": [the count per ruling]
                "count_per_study_by_ruling: [the count per study and ruling]
            }
        ]

    The idea here is to have the grouped counts easily accessible to javascript, such that the
{'fraction_non_alphanumeric': 0.08261617900172118, 'fraction_numerical': 0.0, 'mean_word_length': 3.250457038391225, 'pattern_counts': {'":': 6, '<': 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': '4778460', 'n_tokens_mistral': 694, 'n_tokens_neox': 651, 'n_words': 188}