<commit_before>import React from "react"
import Header from './Header.jsx';
import traverseTree from "../model/traverseTree"
import AlmostDoneAnimation from './AlmostDoneAnimation.jsx';
import Recap from './Recap.jsx';
import SuccessAnimation from './SuccessAnimation.jsx';
import Footer from "./Footer.jsx"

function openOverlay () {
    document.getElementById('recap-overlay').style.height = "100%";
}

function closeOverlay () {
    document.getElementById('recap-overlay').style.height = "0%";
}


class Results extends React.Component {
    constructor (props) {
        super(props);
        this.state = {uploadDone: false, duration: null};
        this.componentDidMount = this.componentDidMount.bind(this);
    }

    componentDidMount () {
        this.setDuration();
    }

    setDuration () {
        let component = this;
        let start = this.props.startTimeStamp;
        let end = Date.now();
        component.setState({
            duration: end - start
        })
    }

    getReorderedNodes () {
        return traverseTree(this.props.rootNode)
    }

    updateBoard () {
        let component = this;

        function showUploadDone () {
            component.setState({
                uploadDone: true
            })
        }

        let reorderedNodes = this.getReorderedNodes().reverse();
        let putCalls = reorderedNodes.length;
        if (gaTrackingId && this.state.duration !== null) {
            console.log('Finished in ' + this.state.duration + ' ms with ' + putCalls + ' cards');
            ga('send', {
                hitType: 'event',
                eventCategory: 'Time stats',
                eventAction: putCalls,
                eventLabel: this.state.duration
            });
        }
        let Trello = this.props.Trello;

        let nextCardIndex = 0;

        function placeNextCard () {
            if (nextCardIndex >= reorderedNodes.length) {
                showUploadDone();
                return;
            }
            Trello.put('/cards/' + reorderedNodes[nextCardIndex].value.id, {pos: 'top'}, placeNextCard, restart);
            nextCardIndex++;
        }

        function restart () {
            nextCardIndex = 0;
            placeNextCard({pos: null});
        }

        placeNextCard({pos: null});
    }

    renderUploadDone () {
        return <div className="send-success__container">
            <SuccessAnimation/>
            <div className="send-success__heading">Prioritization complete!</div>
            <div className="success-buttons__container">
                <a href={"https://trello.com/b/" + this.props.rootNode.value.idBoard} target="_blank"
                   className={"button__primary button__text check-trello__button"}>
                    <i className="fa fa-trello"></i>&nbsp;
                    Check your Trello board
                </a>
                <a href="/" className={"button__primary button__text prioritize-again__button"}>
                    <i className="fa fa-repeat"></i>&nbsp;
                    Prioritize another list
                </a>
            </div>
        </div>
    }

    renderAlmostDone () {
        return <div>
            <AlmostDoneAnimation/>
            <div className="send-ordered__heading">Almost done!</div>
            <div className="send-ordered__button button__primary button__text"<commit_msg>Fix prioritize another list link<commit_after>import React from "react"
import Header from './Header.jsx';
import traverseTree from "../model/traverseTree"
import AlmostDoneAnimation from './AlmostDoneAnimation.jsx';
import Recap from './Recap.jsx';
import SuccessAnimation from './SuccessAnimation.jsx';
import Footer from "./Footer.jsx"

function openOverlay () {
    document.getElementById('recap-overlay').style.height = "100%";
}

function closeOverlay () {
    document.getElementById('recap-overlay').style.height = "0%";
}


class Results extends React.Component {
    constructor (props) {
        super(props);
        this.state = {uploadDone: false, duration: null};
        this.componentDidMount = this.componentDidMount.bind(this);
    }

    componentDidMount () {
        this.setDuration();
    }

    setDuration () {
        let component = this;
        let start = this.props.startTimeStamp;
        let end = Date.now();
        component.setState({
            duration: end - start
        })
    }

    getReorderedNodes () {
        return traverseTree(this.props.rootNode)
    }

    updateBoard () {
        let component = this;

        function showUploadDone () {
            component.setState({
                uploadDone: true
            })
        }

        let reorderedNodes = this.getReorderedNodes().reverse();
        let putCalls = reorderedNodes.length;
        if (gaTrackingId && this.state.duration !== null) {
            console.log('Finished in ' + this.state.duration + ' ms with ' + putCalls + ' cards');
            ga('send', {
                hitType: 'event',
                eventCategory: 'Time stats',
                eventAction: putCalls,
                eventLabel: this.state.duration
            });
        }
        let Trello = this.props.Trello;

        let nextCardIndex = 0;

        function placeNextCard () {
            if (nextCardIndex >= reorderedNodes.length) {
                showUploadDone();
                return;
            }
            Trello.put('/cards/' + reorderedNodes[nextCardIndex].value.id, {pos: 'top'}, placeNextCard, restart);
            nextCardIndex++;
        }

        function restart () {
            nextCardIndex = 0;
            placeNextCard({pos: null});
        }

        placeNextCard({pos: null});
    }

    renderUploadDone () {
        return <div className="send-success__container">
            <SuccessAnimation/>
            <div className="send-success__heading">Prioritization complete!</div>
            <div className="success-buttons__container">
                <a href={"https://trello.com/b/" + this.props.rootNode.value.idBoard} target="_blank"
                   className={"button__primary button__text check-trello__button"}>
                    <i className="fa fa-trello"></i>&nbsp;
                    Check your Trello board
                </a>
                <a href="/app.html" className={"button__primary button__text prioritize-again__button"}>
                    <i className="fa fa-repeat"></i>&nbsp;
                    Prioritize another list
                </a>
            </div>
        </div>
    }

    renderAlmostDone () {
        return <div>
            <AlmostDoneAnimation/>
            <div className="send-ordered__heading">Almost done!</div>
            <div className="send-ordered__button button__primary button__text"
{'fraction_non_alphanumeric': 0.1183528366167975, 'fraction_numerical': 0.0017775144423048438, 'mean_word_length': 1.9666080843585236, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 2, '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': '6680948', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1740, 'n_words': 369}