<commit_before>'use strict';

var Product =  function(){

  var mongoose = require('mongoose')
    , Schema = mongoose.Schema
    , troop = require('mongoose-troop')
    , config = require('config')
    , knox = require('knox')
    , fileValidate = require('../helpers/fileValidate')
    , validateFile = require('../helpers/validateFile')
    , fs = require('fs')
    , slugify = require('../helpers/slugify')
    , async = require('async')
    ;

  // create fileclient to upload and remove product images to aws s3
  var client = knox.createClient({
      key: config.aws.key
    , secret: config.aws.secret
    , bucket: config.aws.bucket
  });

  var ProductSchema = mongoose.Schema({
      name: { type: String, required: true, unique: true }
    , description: { type: String }
    , url: { type: String }
    , category: { type: Schema.Types.ObjectId, ref: 'Category' }
    , image: { type: String }
  });

  // adds created and updated timestamps to the document
  ProductSchema.plugin(troop.timestamp, {modifiedPath: 'updated', useVirtual: false});

  ProductSchema.pre('save', function(next) {
    this.url = slugify(this.name);
    return next();
  });

  ProductSchema.methods.getImagePath = function () {
    var imagePath = 'https://s3.amazonaws.com/' + bucket + '/static/img/products/' + this.image;
    return imagePath;
  };

  ProductSchema.methods.updateImagePath = function (imagePath, fn) {
    // add imagePath to product image property
    this.image = imagePath;
    this.save(function(err, saved){
      return fn(err, saved);
    });
  };

  ProductSchema.statics.uploadImage = function (pid, file, fn) {
    var fileExt
      , product
      , imagePath
      , savedImage
      , awsPath = 'static/img/products/' + imagePath
      , headers = { 'x-amz-acl': 'public-read' }
      ;

    async.series([
      // validate file and get extension
      function (callback){
        validateFile(file.name, function (err, ext){<commit_msg>modified config var to aws<commit_after>'use strict';

var Product =  function(){

  var mongoose = require('mongoose')
    , Schema = mongoose.Schema
    , troop = require('mongoose-troop')
    , aws = require('config').aws
    , knox = require('knox')
    , fileValidate = require('../helpers/fileValidate')
    , validateFile = require('../helpers/validateFile')
    , fs = require('fs')
    , slugify = require('../helpers/slugify')
    , async = require('async')
    ;

  // create fileclient to upload and remove product images to aws s3
  var client = knox.createClient({
      key: aws.key
    , secret: aws.secret
    , bucket: aws.bucket
  });

  var ProductSchema = mongoose.Schema({
      name: { type: String, required: true, unique: true }
    , description: { type: String }
    , url: { type: String }
    , category: { type: Schema.Types.ObjectId, ref: 'Category' }
    , image: { type: String }
  });

  // adds created and updated timestamps to the document
  ProductSchema.plugin(troop.timestamp, {modifiedPath: 'updated', useVirtual: false});

  ProductSchema.pre('save', function(next) {
    this.url = slugify(this.name);
    return next();
  });

  ProductSchema.methods.getImagePath = function () {
    var imagePath = 'https://s3.amazonaws.com/' + aws.bucket + '/static/img/products/' + this.image;
    return imagePath;
  };

  ProductSchema.methods.updateImagePath = function (imagePath, fn) {
    // add imagePath to product image property
    this.image = imagePath;
    this.save(function(err, saved){
      return fn(err, saved);
    });
  };

  ProductSchema.statics.uploadImage = function (pid, file, fn) {
    var fileExt
      , product
      , imagePath
      , savedImage
      , awsPath = 'static/img/products/' + imagePath
      , headers = { 'x-amz-acl': 'public-read' }
      ;

    async.series([
      // validate file and get extension
      function (callback){
        validateFile(file.name, function (err, ext){
{'fraction_non_alphanumeric': 0.14198317614070863, 'fraction_numerical': 0.0010196278358399185, 'mean_word_length': 2.9161676646706587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4693504', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1195, 'n_words': 291}