<commit_before>  var config = require("./config.js").get;
  
  // calculate the urlstub
  var urlstub = config.cloudant.server.replace("//","//"+config.cloudant.username+":"+config.cloudant.password+"@") + ":"+config.cloudant.port;
  
  // start up the nano driver
  var nano = require('nano')(urlstub);
  
  // connections to databases                               
  var feeds = nano.db.use('feeds');
  var articles = nano.db.use('articles');
  
  // async library
  var async = require('async');
  
  // create the feeds database
  var createFeeds = function(callback) {
    console.log("Checking feeds database");
    // create some databases
    nano.db.create('feeds',function(err,body) {
      callback()
    });
  }
  
  // create the articles database
  var createArticles = function(callback) {
    console.log("Checking articles database");
    // create some databases
    nano.db.create('articles',function(err,body) {
      callback()
    });
  }
  
  // create any required views
  var createViews = function(callback) {
    
    var views =  [
  		 {
         "_id": "_design/matching",
         "language": "javascript",
         "views": {
  					 "byts":  {
  					   "map": "function(doc) {if(doc.starred) {emit(['starred',doc.pubDateTS],null);} if(doc.read) {emit(['read',doc.pubDateTS],null);} if(!doc.read) {emit(['unread',doc.pubDateTS],null);} }",
  					   "reduce": "_count"
  					 }
         }
      }	
  	];	
    
    console.log("Checking views");
    for(var i in views) {
      var v = views[i];
      articles.get(v._id,function(err,data) {
        if(!err) {
          var rev = data._rev;
          delete data._rev;
          if(JSON.stringify(data) != JSON.stringify(v)) {
            console.log("view different!");
            v._rev=rev
            articles.insert(v,function(err,data) {
              console.log(err,data);
            });
          }
        }
      })<commit_msg>fixed bug when creating views for the first time<commit_after>  var config = require("./config.js").get;
  
  // calculate the urlstub
  var urlstub = config.cloudant.server.replace("//","//"+config.cloudant.username+":"+config.cloudant.password+"@") + ":"+config.cloudant.port;
  
  // start up the nano driver
  var nano = require('nano')(urlstub);
  
  // connections to databases                               
  var feeds = nano.db.use('feeds');
  var articles = nano.db.use('articles');
  
  // async library
  var async = require('async');
  
  // create the feeds database
  var createFeeds = function(callback) {
    console.log("Checking feeds database");
    // create some databases
    nano.db.create('feeds',function(err,body) {
      callback()
    });
  }
  
  // create the articles database
  var createArticles = function(callback) {
    console.log("Checking articles database");
    // create some databases
    nano.db.create('articles',function(err,body) {
      callback()
    });
  }
  
  // create any required views
  var createViews = function(callback) {
    
    var views =  [
  		 {
         "_id": "_design/matching",
         "language": "javascript",
         "views": {
  					 "byts":  {
  					   "map": "function(doc) { if(doc.starred) {emit(['starred',doc.pubDateTS],null);} if(doc.read) {emit(['read',doc.pubDateTS],null);} if(!doc.read) {emit(['unread',doc.pubDateTS],null);} }",
  					   "reduce": "_count"
  					 }
         }
      }	
  	];	
    
    console.log("Checking views");
    for(var i in views) {
      var v = views[i];
      articles.get(v._id,function(err,data) {
        if(!data) {
          data= {};
          var rev=null;
        } else {
          var rev = data._rev;
          delete data._rev;
        }

        if(JSON.stringify(data) != JSON.stringify(v)) {
          if(rev) {
            v._rev=rev
          }
          articles.insert(v,function(err,data) {
          });
        }
        
      })
{'fraction_non_alphanumeric': 0.1604716739297616, 'fraction_numerical': 0.0, 'mean_word_length': 2.1391794046661303, 'pattern_counts': {'":': 16, '<': 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': '5483191', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1224, 'n_words': 232}