<commit_before>export default class Order {
  constructor({ products = [], totalValue = 0 }) {
    this.products = products;
    this.totalValue = totalValue;
  }

  updateTotalValue() {
    this.totalValue = 0;
    this.products.forEach((product) => {
      this.totalValue += product.productQuantity *
          (product.productOrderIngredients.sumAdditionalPrice() + product.product.unitPrice);
    });
  }

  addProduct(productOrder) {
    const productIndex = this.products.findIndex(p => productOrder.equalTo(p));
    if (productIndex >= 0) {
      this.products[productIndex].productQuantity += productOrder.productQuantity;
    } else {
      this.products.push(productOrder);
    }
    this.updateTotalValue();
  }

  removeProduct(productOrder, quantity) {
    const { products } = this;
    const productIndex = products.findIndex(p => productOrder.equalTo(p));

    if (productIndex < 0) return;

    if (products[productIndex].productQuantity <= 1) {
      products.splice(productIndex);
      return;
    }

    products[productIndex].productQuantity -= quantity;

    this.updateTotalValue();
  }
}<commit_msg>add function to get products qntt total in order<commit_after>export default class Order {
  constructor({ products = [], totalValue = 0 }) {
    this.products = products;
    this.totalValue = totalValue;
  }

  updateTotalValue() {
    this.totalValue = 0;
    this.products.forEach((product) => {
      this.totalValue += product.productQuantity *
          (product.productOrderIngredients.sumAdditionalPrice() + product.product.unitPrice);
    });
  }

  quantity() {
    let quantity = 0;
    this.products.forEach((product) => {
      quantity += product.productQuantity;
    });
    return quantity;
  }

  addProduct(productOrder) {
    const productIndex = this.products.findIndex(p => productOrder.equalTo(p));
    if (productIndex >= 0) {
      this.products[productIndex].productQuantity += productOrder.productQuantity;
    } else {
      this.products.push(productOrder);
    }
    this.updateTotalValue();
  }

  removeProduct(productOrder, quantity) {
    const { products } = this;
    const productIndex = products.findIndex(p => productOrder.equalTo(p));

    if (productIndex < 0) return;

    if (products[productIndex].productQuantity <= 1) {
      products.splice(productIndex);
      return;
    }

    products[productIndex].productQuantity -= quantity;

    this.updateTotalValue();
  }
}
{'fraction_non_alphanumeric': 0.12540983606557377, 'fraction_numerical': 0.004508196721311476, 'mean_word_length': 3.366726296958855, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, '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': '3471344', 'n_tokens_mistral': 726, 'n_tokens_neox': 683, 'n_words': 125}