<commit_before>(function(){
/**
 * Provide a synchronous Collection API using fibers, backed by
 * MongoDB.  This is only for use on the server, and mostly identical
 * to the client API.
 *
 * NOTE: the public API methods must be run within a fiber. If you call
 * these outside of a fiber they will explode!
 */

var path = __meteor_bootstrap__.require('path');
var MongoDB = __meteor_bootstrap__.require('mongodb');
var Future = __meteor_bootstrap__.require(path.join('fibers', 'future'));
var urlModule = __meteor_bootstrap__.require('url');

_Mongo = function (url) {
  var self = this;

  self.collection_queue = [];

  self._liveResultsSets = {};

  // Set autoReconnect on Mongo URLs by default.
  var parsedUrl = urlModule.parse(url, true);
  if (!_.has(parsedUrl.query, 'autoReconnect'))
    parsedUrl.query.autoReconnect = 'true';
  url = urlModule.format(parsedUrl);

  MongoDB.connect(url, {db: {safe: true}}, function(err, db) {
    if (err)
      throw err;
    self.db = db;

    // drain queue of pending callbacks
    var c;
    while ((c = self.collection_queue.pop())) {
      Fiber(function () {
        db.collection(c.name, c.callback);
      }).run();
    }
  });<commit_msg>Fix autoReconnect Mongo URL addition<commit_after>(function(){
/**
 * Provide a synchronous Collection API using fibers, backed by
 * MongoDB.  This is only for use on the server, and mostly identical
 * to the client API.
 *
 * NOTE: the public API methods must be run within a fiber. If you call
 * these outside of a fiber they will explode!
 */

var path = __meteor_bootstrap__.require('path');
var MongoDB = __meteor_bootstrap__.require('mongodb');
var Future = __meteor_bootstrap__.require(path.join('fibers', 'future'));
var urlModule = __meteor_bootstrap__.require('url');

_Mongo = function (url) {
  var self = this;

  self.collection_queue = [];

  self._liveResultsSets = {};

  // Set autoReconnect on Mongo URLs by default.
  if (!(/[\?&]autoReconnect/.test(url))) {
    if (/\?/.test(url))
      url += '&autoReconnect=true';
    else
      url += '?autoReconnect=true';
  }

  MongoDB.connect(url, {db: {safe: true}}, function(err, db) {
    if (err)
      throw err;
    self.db = db;

    // drain queue of pending callbacks
    var c;
    while ((c = self.collection_queue.pop())) {
      Fiber(function () {
        db.collection(c.name, c.callback);
      }).run();
    }
  });
{'fraction_non_alphanumeric': 0.13803169307756463, 'fraction_numerical': 0.0, 'mean_word_length': 3.4099264705882355, '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': '6187805', 'n_tokens_mistral': 771, 'n_tokens_neox': 738, 'n_words': 228}