<commit_before>/*

This table stores Orders and provides an instance method for calculating the order total.

The defaultScope of this model loads OrderProduct along with each order.

*/

const { DECIMAL, INTEGER, STRING, TEXT, ENUM } = require('sequelize')

const LineItem = require('./lineitem')
const Product = require('./product')

module.exports = db => db.define('orders', {
  shipping: ENUM('International', 'Overnight', 'Two-day', 'Standard'),
  creditCard: {
    type: INTEGER,
    validate: {
      isCreditCard: true
    }
  },
  instructions: TEXT
})
// {
//   defaultScope: {
//     include: [{ model: LineItem, Product }]
//   },
//   instanceMethods: {
//     calculateTotal: function() {
//       return LineItem.findAll({
//         where: {
//           orderId: this.id
//         }
//       })
//       .then(lineItems =>
//         lineItems.reduce((acc, lineItem) => acc + (lineItem.priceAtOrderTime * lineItem.quantity), 0.00))
//       .catch(err => {
//         throw err
//       })
//     }
//   }
// })

module.exports.associations = (Order, { Address, LineItem, Product }) => {
  Order.hasOne(Address, {as: 'shippingAddress'})
  Order.hasOne(Address, {as: 'billingAddress'})
  Order.belongsToMany(Product, { through: LineItem })
}
<commit_msg>fix: removes cc and dead code from order model<commit_after>/*

This table stores Orders and provides an instance method for calculating the order total.

The defaultScope of this model loads OrderProduct along with each order.

*/

const { DECIMAL, INTEGER, STRING, TEXT, ENUM } = require('sequelize')

module.exports = db => db.define('orders', {
  shipping: ENUM('International', 'Overnight', 'Two-day', 'Standard'),
  instructions: TEXT
})

module.exports.associations = (Order, { Address, LineItem, Product }) => {
  Order.hasOne(Address, {as: 'shippingAddress'})
  Order.hasOne(Address, {as: 'billingAddress'})
  Order.belongsToMany(Product, { through: LineItem })
}

{'fraction_non_alphanumeric': 0.15372750642673522, 'fraction_numerical': 0.0015424164524421595, 'mean_word_length': 3.267543859649123, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '3992031', 'n_tokens_mistral': 609, 'n_tokens_neox': 594, 'n_words': 157}