<commit_before>// dependencies ------------------------------------------------------------------------------

import React                from 'react';
import moment               from 'moment';
import {PanelGroup, Panel}  from 'react-bootstrap';
import scitran              from '../utils/scitran';
import Paginator            from '../common/partials/paginator.component.jsx';
import Spinner              from '../common/partials/spinner.component.jsx';

// component setup ---------------------------------------------------------------------------

export default class Datasets extends React.Component {

    constructor() {
        super();
	    this.state = {
            loading: false,
            datasets: [],
            resultsPerPage: 30,
            page: 0
        };
    }

// life cycle events -------------------------------------------------------------------------

    componentDidMount() {
        let self = this;
        self.setState({loading: true})
        scitran.getProjects(function (datasets) {
            self.setState({datasets: datasets,  loading: false});
        });
    }

    render() {
        let self = this;
        let datasets = this.state.datasets;

        if (datasets.length > 0) {
            var pagesTotal = Math.ceil(datasets.length / this.state.resultsPerPage);
            let paginatedResults = this.paginate(datasets, this.state.resultsPerPage, this.state.page);   

            // map results
            var Results = paginatedResults.map(function (dataset, index){       
                let dateAdded = moment(dataset.timestamp).format('L');
                let timeago   = moment(dataset.timestamp).fromNow(true)
                
                let datasetheader = (
                    <div className="header clearfix">
                        <h4 className="dataset">{dataset.name}</h4>
                        <div className="date">{dateAdded}<span className="time-ago">{timeago}</span></div>
                    </div>
                );
                
                return (
                    <Panel className="fadeIn" header={datasetheader} eventKey={dataset._id} key={index}><commit_msg>reversed datasets so most recent show first<commit_after>// dependencies ------------------------------------------------------------------------------

import React                from 'react';
import moment               from 'moment';
import {PanelGroup, Panel}  from 'react-bootstrap';
import scitran              from '../utils/scitran';
import Paginator            from '../common/partials/paginator.component.jsx';
import Spinner              from '../common/partials/spinner.component.jsx';

// component setup ---------------------------------------------------------------------------

export default class Datasets extends React.Component {

    constructor() {
        super();
	    this.state = {
            loading: false,
            datasets: [],
            resultsPerPage: 30,
            page: 0
        };
    }

// life cycle events -------------------------------------------------------------------------

    componentDidMount() {
        let self = this;
        self.setState({loading: true})
        scitran.getProjects(function (datasets) {
            datasets.reverse();
            self.setState({datasets: datasets,  loading: false});
        });
    }

    render() {
        let self = this;
        let datasets = this.state.datasets;

        if (datasets.length > 0) {
            var pagesTotal = Math.ceil(datasets.length / this.state.resultsPerPage);
            let paginatedResults = this.paginate(datasets, this.state.resultsPerPage, this.state.page);   

            // map results
            var Results = paginatedResults.map(function (dataset, index){       
                let dateAdded = moment(dataset.timestamp).format('L');
                let timeago   = moment(dataset.timestamp).fromNow(true)
                
                let datasetheader = (
                    <div className="header clearfix">
                        <h4 className="dataset">{dataset.name}</h4>
                        <div className="date">{dateAdded}<span className="time-ago">{timeago}</span></div>
                    </div>
                );
                
                return (
                    <Panel className="fadeIn" header={datasetheader} eventKey={dataset._id} key={index}>
{'fraction_non_alphanumeric': 0.20446265938069216, 'fraction_numerical': 0.00273224043715847, 'mean_word_length': 1.3108890057864282, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '360778', 'n_tokens_mistral': 1019, 'n_tokens_neox': 978, 'n_words': 224}