<commit_before>import React, { PropTypes, Component } from 'react';
import shouldPureComponentUpdate from '../../../../node_modules/react-pure-render/function';
import selectn from 'selectn';
import ThreadContent from './ThreadContent';
import ThreadUsers from './ThreadUsers';

export default class ThreadList extends Component {
    static propTypes = {
        threads: PropTypes.object.isRequired
    };

    shouldComponentUpdate = shouldPureComponentUpdate;

    render() {
        let threadList = [];
        let threadsLength = Object.keys(this.props.threads).length;
        let counter = 0;
        for (let threadId in this.props.threads) {
            let thread = selectn('threads['+threadId+']', this.props);
            if (thread) {
                threadList[counter++] = thread.category === 'ThreadUsers' ?
                    <ThreadUsers thread={thread} last={counter == threadsLength} /> :
                    <ThreadContent thread={thread} last={counter == threadsLength} />;
            }
        }

        return (
            <div>
                {threadList.map(thread => thread)}
            </div>
        );
    }

}<commit_msg>QS-901: Add object lenght function<commit_after>import React, { PropTypes, Component } from 'react';
import shouldPureComponentUpdate from '../../../../node_modules/react-pure-render/function';
import selectn from 'selectn';
import ThreadContent from './ThreadContent';
import ThreadUsers from './ThreadUsers';

export default class ThreadList extends Component {
    static propTypes = {
        threads: PropTypes.object.isRequired
    };

    shouldComponentUpdate = shouldPureComponentUpdate;

    render() {
        let threadList = [];
        let threadsLength = this.getObjectLength(this.props.threads);
        let counter = 0;
        for (let threadId in this.props.threads) {
            let thread = selectn('threads['+threadId+']', this.props);
            if (thread) {
                threadList[counter++] = thread.category === 'ThreadUsers' ?
                    <ThreadUsers thread={thread} last={counter == threadsLength} /> :
                    <ThreadContent thread={thread} last={counter == threadsLength} />;
            }
        }

        return (
            <div>
                {threadList.map(thread => thread)}
            </div>
        );
    }

    getObjectLength = function(obj) {
        let size = 0, key;
        for (key in obj) {
            if (obj.hasOwnProperty(key)) size++;
        }
        return size;
    };

}
{'fraction_non_alphanumeric': 0.1248513674197384, 'fraction_numerical': 0.0023781212841854932, 'mean_word_length': 2.203045685279188, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '3385929', 'n_tokens_mistral': 654, 'n_tokens_neox': 635, 'n_words': 159}