<commit_before>var MongoClient = require('mongodb').MongoClient,
    settings = require('./config.js'),
    Converter = require("csvtojson").Converter,
    httpRequest = require('request');

var fullMongoUrl = settings.mongoConfig.serverUrl + settings.mongoConfig.database;
var exports = module.exports = {};

// Create "tickers" collection if it does not already exist
MongoClient.connect(fullMongoUrl)
    .then(function(db) {
        db.createCollection("historicalData");
    });

// Exported mongo functions
MongoClient.connect(fullMongoUrl)
    .then(function(db) {
        var tickerCollection = db.collection("historicalData");

        exports.checkDates = function(symbol,start,end) {
            // Try to find ticker in the database
            //symbol = "AAPL";
            //start = 10201;
            return tickerCollection.find({Symbol: symbol}).sort({Date: -1}).toArray().then(function(ticker) {
              //console.log(ticker);
                if (ticker.length) {
                  var lastDate = ticker[0].Date;
                  return lastDate;
                } else {
                    return null;
                }
            });
        };
        exports.addTicker = function(symbol, data){
          //var parseDate = d3.time.format("%Y-%m-%d").parse;
          // data.forEach(function(day) {
          //   console.log(day.Date);
          //   //tickerCollection.update({symbol: symbol}, {$set: {symbol: symbol, date: day.Date, price: day.Open}}, {upsert: true});
          // });
          // data.forEach(function(day) {
          //   day.Date = new Date(day.Date).toISOString().split('T')[0];;
          // });
          return tickerCollection.insertMany(data).then(function() {
              return tickerCollection.find().toArray();
          });
        };

        exports.getData = function(symbol, start, end){
          // data.forEach(function(day) {
          //   console.log(day.Date);
          //   //tickerCollection.update({symbol: symbol}, {$set: {symbol: symbol, date: day.Date, price: day.Open}}, {upsert: true});
          // });
          return tickerCollection.find({Symbol: symbol, Date: {$gte: start, $lte: end}}).toArray().then(function(data){
            return data;
          });

        };

      };
    });<commit_msg>small error<commit_after>var MongoClient = require('mongodb').MongoClient,
    settings = require('./config.js'),
    Converter = require("csvtojson").Converter,
    httpRequest = require('request');

var fullMongoUrl = settings.mongoConfig.serverUrl + settings.mongoConfig.database;
var exports = module.exports = {};

// Create "tickers" collection if it does not already exist
MongoClient.connect(fullMongoUrl)
    .then(function(db) {
        db.createCollection("historicalData");
    });

// Exported mongo functions
MongoClient.connect(fullMongoUrl)
    .then(function(db) {
        var tickerCollection = db.collection("historicalData");

        exports.checkDates = function(symbol,start,end) {
            // Try to find ticker in the database
            //symbol = "AAPL";
            //start = 10201;
            return tickerCollection.find({Symbol: symbol}).sort({Date: -1}).toArray().then(function(ticker) {
              //console.log(ticker);
                if (ticker.length) {
                  var lastDate = ticker[0].Date;
                  return lastDate;
                } else {
                    return null;
                }
            });
        };
        exports.addTicker = function(symbol, data){
          //var parseDate = d3.time.format("%Y-%m-%d").parse;
          // data.forEach(function(day) {
          //   console.log(day.Date);
          //   //tickerCollection.update({symbol: symbol}, {$set: {symbol: symbol, date: day.Date, price: day.Open}}, {upsert: true});
          // });
          // data.forEach(function(day) {
          //   day.Date = new Date(day.Date).toISOString().split('T')[0];;
          // });
          return tickerCollection.insertMany(data).then(function() {
              return tickerCollection.find().toArray();
          });
        };

        exports.getData = function(symbol, start, end){
          // data.forEach(function(day) {
          //   console.log(day.Date);
          //   //tickerCollection.update({symbol: symbol}, {$set: {symbol: symbol, date: day.Date, price: day.Open}}, {upsert: true});
          // });
          return tickerCollection.find({Symbol: symbol, Date: {$gte: start, $lte: end}}).toArray().then(function(data){
            return data;
          });

        };


    });
{'fraction_non_alphanumeric': 0.15589519650655023, 'fraction_numerical': 0.003930131004366812, 'mean_word_length': 2.0703753351206435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6371067', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1274, 'n_words': 237}