<commit_before>import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { sumBy } from 'lodash';

export default Controller.extend({
  hasTicketsInOrder: computed('model.tickets.@each.orderQuantity', function() {
    return sumBy(this.get('model.tickets').toArray(),
      ticket => ticket.getWithDefault('orderQuantity', 0)
    ) > 0;
  }),
  total: computed('model.tickets.@each.orderQuantity', function() {
    let sum = 0.0;
    this.get('model.tickets').forEach(ticket => {
      sum += ticket.get('orderQuantity') * ticket.get('price');
    });
    return sum;
  }),
  columns: [
    {
      propertyName : 'name',
      title        : 'Ticket Type'
    },
    {
      propertyName   : 'price',
      title          : 'Price',
      template       : 'components/ui-table/cell/events/view/tickets/cell-add-order-price',
      disableSorting : true
    },
    {
      propertyName : 'quantity',
      title        : 'Quantity',
      template     : 'components/ui-table/cell/events/view/tickets/cell-add-order-quantity'
    },
    {
      propertyName : 'itemTotal',
      title        : 'Item Total',
      template     : 'components/ui-table/cell/events/view/tickets/cell-add-order-total'
    }
  ],

  actions: {
    updateOrder(ticket, count) {
      let order = this.get('model.order');
      ticket.set('orderQuantity', count);
      order.set('amount', this.get('total'));
      if (!this.get('total')) {
        order.set('amount', 0);
      }
      if (count > 0) {
        order.tickets.addObject(ticket);
      } else {
        if (order.tickets.includes(ticket)) {
          order.tickets.removeObject(ticket);
        }
      }<commit_msg>Enabled sorting in ember table on basis of ticket price (#2814)<commit_after>import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { sumBy } from 'lodash';

export default Controller.extend({
  hasTicketsInOrder: computed('model.tickets.@each.orderQuantity', function() {
    return sumBy(this.get('model.tickets').toArray(),
      ticket => ticket.getWithDefault('orderQuantity', 0)
    ) > 0;
  }),
  total: computed('model.tickets.@each.orderQuantity', function() {
    let sum = 0.0;
    this.get('model.tickets').forEach(ticket => {
      sum += ticket.get('orderQuantity') * ticket.get('price');
    });
    return sum;
  }),
  columns: [
    {
      propertyName : 'name',
      title        : 'Ticket Type'
    },
    {
      propertyName : 'price',
      title        : 'Price',
      template     : 'components/ui-table/cell/events/view/tickets/cell-add-order-price'
    },
    {
      propertyName : 'quantity',
      title        : 'Quantity',
      template     : 'components/ui-table/cell/events/view/tickets/cell-add-order-quantity'
    },
    {
      propertyName : 'itemTotal',
      title        : 'Item Total',
      template     : 'components/ui-table/cell/events/view/tickets/cell-add-order-total'
    }
  ],

  actions: {
    updateOrder(ticket, count) {
      let order = this.get('model.order');
      ticket.set('orderQuantity', count);
      order.set('amount', this.get('total'));
      if (!this.get('total')) {
        order.set('amount', 0);
      }
      if (count > 0) {
        order.tickets.addObject(ticket);
      } else {
        if (order.tickets.includes(ticket)) {
          order.tickets.removeObject(ticket);
        }
      }
{'fraction_non_alphanumeric': 0.15857605177993528, 'fraction_numerical': 0.004707266843189173, 'mean_word_length': 2.4623217922606924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '4920', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1036, 'n_words': 178}