<commit_before>/*
* Copyright 2015 CareerBuilder, LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*     http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
var amazon = require('aws-sdk');

var db = new amazon.SimpleDB({
  apiVersion: '2009-04-15',
  credentials: global.config.DB.credentials,
  region: "us-east-1"
});

var user_domain = "TestDomain";

module.exports ={
  to_object_id: function(id){
    return mongo.helper.toObjectID(id);
  },
  put_user: function(user, callback){

    var params = {
      Attributes:[],
      DomainName: user_domain,
      ItemName: user.email
    };
    for(var field in user){
      params.Attributes.push(
        {
          Name: field,
          Value: user[field].toString(),
          Replace: false
        }
      )
    }
    console.log(params);
    db.putAttributes(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     callback(data);           // successful response
    });

  },
  update_user: function(user, k_v, callback){

    var select_expr =
    var set = {$set: k_v};
    db.collection('users').update(user, set, callback);
  },
  get_user: function(user_args, callback){

    var select_expr = "select * from " + user_domain + " where ";
    var prop_count = Object.keys(user_args).length;
    var current_count = 1;

    for(var field in user_args){
      select_expr  = select_expr + field + " = '" + user_args[field] + "'";
      if(current_count < prop_count){
        select_expr = select_expr + " and ";
      }
      current_count = current_count + 1;
    }

    console.log(select_expr);
    var params = {
      SelectExpression: select_expr, /* required */
      ConsistentRead: true,
    };
    db.select(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     callback(data);           // successful response
    });
  },
  get_parts: function(parts, callback){
    var criteria = parts || {};
    db.collection('parts').find(criteria).toArray(callback);
  },
  get_part: function(part, callback){
    db.collection('parts').findOne(part, callback);
  },
  get_stacks: function(stacks, callback){
    var criteria = stacks || {};
    db.collection('stacks').find(criteria).toArray(callback);
  },
  get_stack: function(stack, callback){
    db.collection('stacks').findOne(stack, callback);
  },
  put_stack: function(stack, k_v, callback){
    db.collection.update(stack, k_v, {upsert:true}, callback);
  },
  test_database: function(whatever, callback){

    var params = {
      DomainName: 'TestDomain', /* required */
      ItemName: '<EMAIL>', /* required */
      ConsistentRead: true
    };
    db.getAttributes(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     console.log(data);           // successful response
    });
  },
  test_database_put: function(err, data){

    var params = {
      Attributes:
      [
        {
          Name: 'email',
          Value: '<EMAIL>',
          Replace: true
        },

        {
          Name: 'team',
          Value: 'Search',
          Replace: false
        }

    ],
    DomainName: 'TestDomain',
    ItemName: '<EMAIL>',
    };
    db.putAttributes(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     console.log(data);           // successful response
    });

  }


  //Create Domain (Table)
  /*
  db.createDomain({
    DomainName: "TestDomain"
  },
  function(err, data){
    if(err) console.log(err, err.stack)
    else console.log(data);
  })
  */

  //Getting Domains (Tables)
  /*
  var params = {
    MaxNumberOfDomains: 10,
    NextToken: 'STRING_VALUE'
  };
  db.listDomains(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
  });
  */

  //Adding Rows
  /*
  var params = {
    Attributes:
    [
      {
        Name: 'email',
        Value: '<EMAIL>',
        Replace: true
      },

      {
        Name: 'team',
        Value: 'Search',
        Replace: false
      }

  ],
  DomainName: 'TestDomain',
  ItemName: 'user',
};
db.putAttributes(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});
  */

  //Getting Rows
}<commit_msg>chop broken code for testing<commit_after>/*
* Copyright 2015 CareerBuilder, LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
var amazon = require('aws-sdk');

var db = new amazon.SimpleDB({
  apiVersion: '2009-04-15',
  credentials: global.config.DB.credentials,
  region: "us-east-1"
});

var user_domain = "TestDomain";

module.exports ={
  put_user: function(user, callback){

    var params = {
      Attributes:[],
      DomainName: user_domain,
      ItemName: user.email
    };
    for(var field in user){
      params.Attributes.push(
        {
          Name: field,
          Value: user[field].toString(),
          Replace: false
        }
      )
    }
    console.log(params);
    db.putAttributes(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     callback(data);           // successful response
    });

  },
  update_user: function(user, k_v, callback){

    //var select_expr =
    var set = {$set: k_v};
    db.collection('users').update(user, set, callback);
  },
  get_user: function(user_args, callback){

    var select_expr = "select * from " + user_domain + " where ";
    var prop_count = Object.keys(user_args).length;
    var current_count = 1;

    for(var field in user_args){
      select_expr  = select_expr + field + " = '" + user_args[field] + "'";
      if(current_count < prop_count){
        select_expr = select_expr + " and ";
      }
      current_count = current_count + 1;
    }

    console.log(select_expr);
    var params = {
      SelectExpression: select_expr, /* required */
      ConsistentRead: true,
    };
    db.select(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     callback(data);           // successful response
    });
  },
  get_parts: function(parts, callback){
    var criteria = parts || {};
    db.collection('parts').find(criteria).toArray(callback);
  },
  get_part: function(part, callback){
    db.collection('parts').findOne(part, callback);
  },
  get_stacks: function(stacks, callback){
    var criteria = stacks || {};
    db.collection('stacks').find(criteria).toArray(callback);
  },
  get_stack: function(stack, callback){
    db.collection('stacks').findOne(stack, callback);
  },
  put_stack: function(stack, k_v, callback){
    db.collection.update(stack, k_v, {upsert:true}, callback);
  },
  test_database: function(whatever, callback){

    var params = {
      DomainName: 'TestDomain', /* required */
      ItemName: '<EMAIL>', /* required */
      ConsistentRead: true
    };
    db.getAttributes(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     console.log(data);           // successful response
    });
  }
}
{'fraction_non_alphanumeric': 0.1348728657413094, 'fraction_numerical': 0.004913401302051345, 'mean_word_length': 2.669220369535827, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5865946', 'n_tokens_mistral': 2515, 'n_tokens_neox': 2444, 'n_words': 639}