<commit_before>import React, { PropTypes, Component } from 'react';
import LeftMenuTopNavbar from '../components/ui/LeftMenuTopNavbar';
import QuestionStats from '../components/questions/QuestionStats';
import AuthenticatedComponent from '../components/AuthenticatedComponent';
import connectToStores from '../utils/connectToStores';
import UserStore from '../stores/UserStore';
import QuestionStore from '../stores/QuestionStore';
import QuestionsByUserIdStore from '../stores/QuestionsByUserIdStore';

function parseUserId(user) {
    return user.qnoow_id;
}

/**
 * Retrieves state from stores for current props.
 */
function getState(props) {
    const { user } = props;
    const currentUserId = parseUserId(user);
    const currentUser = UserStore.get(currentUserId);
    const question = QuestionStore.getQuestion();
    const userAnswer = QuestionStore.getUserAnswer(currentUserId, question.questionId);

    return {
        currentUser,
        question,
        userAnswer,
        user
    };
}

@connectToStores([UserStore, QuestionStore, QuestionsByUserIdStore], getState)
export default AuthenticatedComponent(class QuestionStatsPage extends Component {
    static propTypes = {

        // Injected by @connectToStores:
        question: PropTypes.object,
        userAnswer: PropTypes.object,

        // Injected by AuthenticatedComponent
        user: PropTypes.object.isRequired
    };

    static contextTypes = {
        history: PropTypes.object.isRequired
    };

    constructor(props) {
        super(props);

        this.handleContinueClick = this.handleContinueClick.bind(this);
    }

    render() {
        const user = this.props.user;
        return (
            <div className="view view-main">
                <LeftMenuTopNavbar centerText={'Estadísticas'} rightText={'Continuar'} onRightLinkClickHandler={this.handleContinueClick} />
                <div data-page="index" className="page question-stats-page">
                    <div id="page-content" className="question-stats-content">
                        {this.props.userAnswer && this.props.question ?
                            <QuestionStats question={this.props.question} userAnswer={this.props.userAnswer} userId={user.qnoow_id}/><commit_msg>QS-916: Fix menu showing in QuestionStatsPage<commit_after>import React, { PropTypes, Component } from 'react';
import LeftMenuTopNavbar from '../components/ui/LeftMenuTopNavbar';
import RegularTopNavbar from '../components/ui/RegularTopNavbar';
import QuestionStats from '../components/questions/QuestionStats';
import AuthenticatedComponent from '../components/AuthenticatedComponent';
import connectToStores from '../utils/connectToStores';
import UserStore from '../stores/UserStore';
import QuestionStore from '../stores/QuestionStore';
import QuestionsByUserIdStore from '../stores/QuestionsByUserIdStore';

function parseUserId(user) {
    return user.qnoow_id;
}

/**
 * Retrieves state from stores for current props.
 */
function getState(props) {
    const { user } = props;
    const currentUserId = parseUserId(user);
    const currentUser = UserStore.get(currentUserId);
    const question = QuestionStore.getQuestion();
    const userAnswer = QuestionStore.getUserAnswer(currentUserId, question.questionId);
    const isJustRegistered = Object.keys(QuestionsByUserIdStore.getByUserId(currentUserId)).length < 4;

    return {
        currentUser,
        question,
        userAnswer,
        user,
        isJustRegistered
    };
}

@connectToStores([UserStore, QuestionStore, QuestionsByUserIdStore], getState)
export default AuthenticatedComponent(class QuestionStatsPage extends Component {
    static propTypes = {

        // Injected by @connectToStores:
        question: PropTypes.object,
        userAnswer: PropTypes.object,
        isJustRegistered: PropTypes.bool,

        // Injected by AuthenticatedComponent
        user: PropTypes.object.isRequired
    };

    static contextTypes = {
        history: PropTypes.object.isRequired
    };

    constructor(props) {
        super(props);

        this.handleContinueClick = this.handleContinueClick.bind(this);
    }

    render() {
        const user = this.props.user;
        return (
            <div className="view view-main">
                {this.props.isJustRegistered ?
                    <RegularTopNavbar centerText={'Estadísticas'} rightText={'Continuar'}/>
                    :
                    <LeftMenuTopNavbar centerText={'Estadísticas'} rightText={'Continuar'} onRightLinkClickHandler={this.handleContinueClick} />
                }

                <div data-page="index" className="page question-stats-page">
                    <div id="page-content" className="question-stats-content">
                        {this.props.userAnswer && this.props.question ?
                            <QuestionStats question={this.props.question} userAnswer={this.props.userAnswer} userId={user.qnoow_id}/>
{'fraction_non_alphanumeric': 0.10461351679481991, 'fraction_numerical': 0.0008093889113719142, 'mean_word_length': 3.1191666666666666, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 14, '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': '4918287', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1284, 'n_words': 269}