<commit_before>import React       from 'react';
import { connect } from 'react-redux';
import { Link }    from 'react-router';
import classNames  from 'classnames'
import { changeStatus } from '../actions'

import AppBarTimer   from './AppBarTimer';

const mapStateToProps = state => {
  return {
    orders: state.orders
  };
};

class Prepare extends React.Component {
  propTypes = {
    orders: React.PropTypes.array
  };

  state = {
    tab: 'notReady'
  }

  onChangeStatusClick(order, status) {
    this.props.changeStatus(order.id, status)
  }

  getOrders() {
    const orders = this.props.orders
      .filter(order => {
        if (this.state.tab === 'notReady') {
          return ((order.status === 'pending') || (order.status === 'prepare'));
        }
        else return order.status === this.state.tab;
      })
      .map(order => {
        return order;
      });

    orders.sort((a, b) => {
      if (a.createdAt - b.createdAt === 0) {
        return a.name.localeCompare(b.name);
      }

      return a.createdAt - b.createdAt;
    });

    const resOrders = [];

    orders.map(order => {
      if (resOrders[resOrders.length - 1] != undefined) {
        if (resOrders[resOrders.length - 1].createdAt != undefined) {
          if ((new Date(order.createdAt).getTime() === new Date(resOrders[resOrders.length - 1].createdAt).getTime())
            && (order.code === resOrders[resOrders.length - 1]["code"])) {
              var temp = [resOrders[resOrders.length - 1], order];
              resOrders[resOrders.length - 1] = temp;
            }
          else resOrders.push(order);
        }
        else if ((new Date(order.createdAt).getTime() === new Date(resOrders[resOrders.length - 1][0].createdAt).getTime())
          && (order.code === resOrders[resOrders.length - 1][0].code)) {
            var temp = resOrders[resOrders.length - 1];
            temp.push(order);
            resOrders[resOrders.length - 1] = temp;
          }
        else resOrders.push(order);
      }
      else resOrders.push(order);
    });

    return resOrders;
  }<commit_msg>changed prep orders to be ordered by createdAt<commit_after>import React       from 'react'
import { connect } from 'react-redux'
import { Link }    from 'react-router'
import classNames  from 'classnames'
import { changeStatus } from '../actions'
import moment from 'moment'

import AppBarTimer   from './AppBarTimer'

const mapStateToProps = state => {
  return {
    orders: state.orders
  };
};

class Prepare extends React.Component {
  propTypes = {
    orders: React.PropTypes.array
  };

  state = {
    tab: 'notReady'
  }

  onChangeStatusClick(order, status) {
    this.props.changeStatus(order.id, status)
  }

  getOrders() {
    const orders = this.props.orders.filter(order => order.status === "pending" || order.status === "prepare" || order.status === "ready")
    orders.sort((a, b) => {
      if (moment(a.createdAt).isAfter(b.createdAt)) return 1
      if (moment(a.createdAt).isBefore(b.createdAt)) return -1
      return 0
    })

    return orders
  }
{'fraction_non_alphanumeric': 0.1475677440417891, 'fraction_numerical': 0.005223636957231472, 'mean_word_length': 2.5381062355658197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2730622', 'n_tokens_mistral': 982, 'n_tokens_neox': 957, 'n_words': 208}