from statsmodels.regression.linear_model import RegressionResults

from src.analysis_functions.specific_analysis.increase_per_up_and_downvote import (
    InfluenceOfUpAndDownvotesOnReplies,
)
from src.data_classes.parameters_analysis_influence_of_up_and_downvotes import (
    InfluenceOfVotesParameters,
)
from src.utils.helper_logging import log_influence_of_up_and_downvotes_on_replies


def run_report_influence_of_up_and_downvotes_on_replies(
    influence_of_up_and_downvotes: InfluenceOfUpAndDownvotesOnReplies,
    analyses_list: list[InfluenceOfVotesParameters],
    regression_models: dict[str, RegressionResults],
) -> None:
    """
    Run specific analyses to find the effect of up-and downvotes on replies based on a list of parameter objects.

    This function iterates over a list of InfluenceOfVotesParameters objects,
    and then calculates the influence of up-and downvotes on replies based on
    the parameters in each object and a given regression model.


    Parameters
    ----------
    influence_of_up_and_downvotes: InfluenceOfUpAndDownvotesOnReplies
        An instance of the InfluenceOfUpAndDownvotesOnReplies class.
    analyses_list: list[PearsonCorrelationParameters
        A list of PearsonCorrelationParameters objects.
        Each object contains the parameters for a single Pearson correlation analysis.
    regression_models: dict[str, RegressionResults]
        A dictionary of regression models, where the key is the model name and the value is the regression model.
        Created via the regression_wrappers.run_regression function.

    Returns
    -------
    None
    """
    for analysis_config in analyses_list:
        log_influence_of_up_and_downvotes_on_replies(analysis_config)

        influence_of_up_and_downvotes.report_increase_per_up_and_downvote_from_totalvotes_and_valence(
            data=analysis_config.data,
            weight_as_distribution_quantile=analysis_config.weight_as_distribution_quantile,
            weight_m=analysis_config.weight_m,
            model=regression_models[analysis_config.model_name],
            step=analysis_config.step,
            startpoint=analysis_config.startpoint,
            name_save_file=analysis_config.name_save_file,
        )
