<commit_before>﻿import * as React from "react";
import StatisticsState from "./../store/statisticsState";
import { connect, Dispatch } from "react-redux";
import { Statistics } from "./../models/statistics";

import { fetchStatistics } from "./../store/statisticsAction";
import { fetchMethods } from "./../store/getRequestMethodsAction";
import { fetchRequestUrls } from "./../store/getRequestUrlsAction";

type StatisticProps =
{
    methods?: string[],
    requestUrls?: string[],
    statistics?: Statistics,
    dispatch?: Dispatch<StatisticsState>
};

export function HttpStatusResultStatistics(props: StatisticProps) {
    var methodOptions = props.methods.map(function(option: any) {
        return (
            <option key={option} value={option}>
                {option}
            </option>
        )
    });

    var requestUrlOptions = props.requestUrls.map(function(option: any) {
        return (
            <option key={option} value={option}>
                {option}
            </option>
        )
    });

    var statusCodeCounts = props.statistics.statusCodeCounts.map(function(item: any) {
        return (
            <tr key={item.statusCode}>
                <td>{item.statusCode} ({item.statusCodeName})</td>
                <td>{item.count}</td>
            </tr>
        )
    });

    var fastestRequestDurations = props.statistics.fastestRequests.map(function(item: any) {
        return (
            <tr key={item.id}>
                <td>{item.elapsedMilliseconds}</td>
                <td>{item.method}</td>
                <td>{item.requestUrl}</td>
                <td>{item.statusCode}</td>
            </tr>
        )
    });

    var slowestRequestDurations = props.statistics.slowestRequests.map(function(item: any) {
        return (
            <tr key={item.id}>
                <td>{item.elapsedMilliseconds}</td>
                <td>{item.method}</td>
                <td>{item.requestUrl}</td>
                <td>{item.statusCode}</td>
            </tr>
        )
    });

    var methodChanged = function(e: any)
    {
        if(e.target.value === props.statistics.method)
        {
            return;
        }

        props.statistics.method = e.target.value;

        props.dispatch(fetchRequestUrls(props.statistics.method));
        props.dispatch(fetchStatistics(props.statistics.method, props.statistics.requestUrl, props.statistics.numberOfStandardDeviations));
    };

    var requestUrlChanged = function(e: any)
    {
        if(e.target.value === props.statistics.requestUrl)
        {
            return;
        }

        props.statistics.requestUrl = e.target.value;

        props.dispatch(fetchMethods(props.statistics.requestUrl));
        props.dispatch(fetchStatistics(props.statistics.method, props.statistics.requestUrl, props.statistics.numberOfStandardDeviations));
    };

    var numberOfStdDevsChanged = function(e: any)
    {
        if(e.target.value === props.statistics.numberOfStandardDeviations)
        {
            return;
        }

        props.statistics.numberOfStandardDeviations = e.target.value;

        props.dispatch(fetchStatistics(props.statistics.method, props.statistics.requestUrl, props.statistics.numberOfStandardDeviations));
    };

    var requestsOutsideOfDeviations = props.statistics.durationCount - props.statistics.durationWithinDeviationsCount;
    var percentageOutsideOfDeviations = (requestsOutsideOfDeviations / props.statistics.durationCount) * 100.0;
    
    

    return (
        <div>
            <h3>Statistics Calculation Options</h3>
            <div>Method: 
                <select value={props.statistics.method} onChange={methodChanged}>
                    <option key='' value='' />
                    {methodOptions}
                </select>
            </div>
            <div>Request: 
                <select value={props.statistics.requestUrl} onChange={requestUrlChanged}>
                    <option key='' value='' />
                    {requestUrlOptions}
                </select>
            </div>
            <div>Number of Std Devs: 
                <input type='text' value={props.statistics.numberOfStandardDeviations} onChange={numberOfStdDevsChanged}>
                </input>
            </div>
            <br/>
            <h3>Result Statistics</h3>
            <div>Average Duration: {props.statistics.averageDuration} ms</div>
            <div>Number of Requests: {props.statistics.durationCount}</div>
            <br/>
            <div>Standard Deviation: {props.statistics.standardDeviation} ms</div>
            <br/>
            <div>Average Duration of Requests within {props.statistics.numberOfStandardDeviations} Std Devs of Avg: {props.statistics.averageDurationWithinDeviations} ms</div><commit_msg>Fixed warnings in console<commit_after>﻿import * as React from "react";
import StatisticsState from "./../store/statisticsState";
import { connect, Dispatch } from "react-redux";
import { Statistics } from "./../models/statistics";

import { fetchStatistics } from "./../store/statisticsAction";
import { fetchMethods } from "./../store/getRequestMethodsAction";
import { fetchRequestUrls } from "./../store/getRequestUrlsAction";

type StatisticProps =
{
    methods?: string[],
    requestUrls?: string[],
    statistics?: Statistics,
    dispatch?: Dispatch<StatisticsState>
};

export function HttpStatusResultStatistics(props: StatisticProps) {
    var methodOptions = props.methods.map(function(option: any) {
        return (
            <option key={option} value={option}>
                {option}
            </option>
        )
    });

    var requestUrlOptions = props.requestUrls.map(function(option: any) {
        return (
            <option key={option} value={option}>
                {option}
            </option>
        )
    });

    var statusCodeCounts = props.statistics.statusCodeCounts.map(function(item: any) {
        return (
            <tr key={item.statusCode}>
                <td>{item.statusCode} ({item.statusCodeName})</td>
                <td>{item.count}</td>
            </tr>
        )
    });

    var fastestRequestDurations = props.statistics.fastestRequests.map(function(item: any) {
        return (
            <tr key={item.id}>
                <td>{item.elapsedMilliseconds}</td>
                <td>{item.method}</td>
                <td>{item.requestUrl}</td>
                <td>{item.statusCode}</td>
            </tr>
        )
    });

    var slowestRequestDurations = props.statistics.slowestRequests.map(function(item: any) {
        return (
            <tr key={item.id}>
                <td>{item.elapsedMilliseconds}</td>
                <td>{item.method}</td>
                <td>{item.requestUrl}</td>
                <td>{item.statusCode}</td>
            </tr>
        )
    });

    var methodChanged = function(e: any)
    {
        if(e.target.value === props.statistics.method)
        {
            return;
        }

        props.statistics.method = e.target.value;

        props.dispatch(fetchRequestUrls(props.statistics.method));
        props.dispatch(fetchStatistics(props.statistics.method, props.statistics.requestUrl, props.statistics.numberOfStandardDeviations));
    };

    var requestUrlChanged = function(e: any)
    {
        if(e.target.value === props.statistics.requestUrl)
        {
            return;
        }

        props.statistics.requestUrl = e.target.value;

        props.dispatch(fetchMethods(props.statistics.requestUrl));
        props.dispatch(fetchStatistics(props.statistics.method, props.statistics.requestUrl, props.statistics.numberOfStandardDeviations));
    };

    var numberOfStdDevsChanged = function(e: any)
    {
        if(e.target.value === props.statistics.numberOfStandardDeviations)
        {
            return;
        }

        props.statistics.numberOfStandardDeviations = e.target.value;

        props.dispatch(fetchStatistics(props.statistics.method, props.statistics.requestUrl, props.statistics.numberOfStandardDeviations));
    };

    var requestsOutsideOfDeviations = props.statistics.durationCount - props.statistics.durationWithinDeviationsCount;
    var percentageOutsideOfDeviations = (requestsOutsideOfDeviations / props.statistics.durationCount) * 100.0;
    
    return (
        <div>
            <h3>Statistics Calculation Options</h3>
            <div>Method: 
                <select value={props.statistics.method || ""} onChange={methodChanged}>
                    <option key='' value='' />
                    {methodOptions}
                </select>
            </div>
            <div>Request: 
                <select value={props.statistics.requestUrl || ""} onChange={requestUrlChanged}>
                    <option key='' value='' />
                    {requestUrlOptions}
                </select>
            </div>
            <div>Number of Std Devs: 
                <input type='text' value={props.statistics.numberOfStandardDeviations} onChange={numberOfStdDevsChanged}>
                </input>
            </div>
            <br/>
            <h3>Result Statistics</h3>
            <div>Average Duration: {props.statistics.averageDuration} ms</div>
            <div>Number of Requests: {props.statistics.durationCount}</div>
            <br/>
            <div>Standard Deviation: {props.statistics.standardDeviation} ms</div>
            <br/>
            <div>Average Duration of Requests within {props.statistics.numberOfStandardDeviations} Std Devs of Avg: {props.statistics.averageDurationWithinDeviations} ms</div>
{'fraction_non_alphanumeric': 0.1254442818314865, 'fraction_numerical': 0.00167259042441982, 'mean_word_length': 2.172082228116711, 'pattern_counts': {'":': 0, '<': 125, '<?xml version=': 0, '>': 125, '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': '7064945', 'n_tokens_mistral': 2686, 'n_tokens_neox': 2566, 'n_words': 422}