<commit_before>'use strict';
/*var io = require('socket.io-client');
var ex_socket = new io.connect("http://192.168.3.11:3006");
var myClock;
var currenttime;

ex_socket.on('connect', function() {
	console.log(">>>> Connected!");
	currenttime = new Date();
	//callBlocks(currenttime);
});

ex_socket.on('disconnect', function() {
	console.log('>>> Clock lost');
});

ex_socket.on('postblocks', function(data){
  	socket.emit('/timeline/#postBlocks', data);
});*/

exports.join = function(app, socket){
	console.log("////////////join//////////////");
  return function() {
    socket.visitor = 'guest';
    if (socket.handshake.user) {
      //socket.visitor = socket.handshake.user.username;
      socket.visitor = socket.handshake.user.id;
    }
    socket.emit('/timeline/#newUser', socket.visitor);
  };
};

exports.callblocks = function(app, socket){
  return function(message) {
	var redis = require("redis"),
	 client = redis.createClient();
	 
	// get max limit
	var timeline_end;
	client.get('global:next_tb_id', function(err,res){
		if (err){
			console.log("error: "+err);
		}
			timeline_end =res;
			getblockIDs();
	});
	
	// convert dates and get block ids
	var beginT = message.begintime;
	var endT = message.endtime;
	console.log(beginT);
	console.log(endT);
	
	var begintime = beginT.getTime();
	var endtime = endT.getTime();
	
	var firstid;
	var lastid;
	var commands = [];
	
	function getblockIDs(){
		client.get("tb_time:"+begintime+":tb_id", function(err,res){
			if (err){
				console.log("error: "+err);
			}
			firstid = res;
			// if out of range<commit_msg>redis migration<commit_after>'use strict';
/*var io = require('socket.io-client');
var ex_socket = new io.connect("http://192.168.3.11:3006");
var myClock;
var currenttime;

ex_socket.on('connect', function() {
	console.log(">>>> Connected!");
	currenttime = new Date();
	//callBlocks(currenttime);
});

ex_socket.on('disconnect', function() {
	console.log('>>> Clock lost');
});

ex_socket.on('postblocks', function(data){
  	socket.emit('/timeline/#postBlocks', data);
});*/

exports.join = function(app, socket){
	console.log("////////////join//////////////");
  return function() {
    socket.visitor = 'guest';
    if (socket.handshake.user) {
      //socket.visitor = socket.handshake.user.username;
      socket.visitor = socket.handshake.user.id;
    }
    socket.emit('/timeline/#newUser', socket.visitor);
  };
};

exports.callblocks = function(app, socket){
  return function(message) {
	var redis = require("redis"),
	 client = redis.createClient();
	 
	// get max limit
	var timeline_end;
	client.get('global:next_tb_id', function(err,res){
		if (err){
			console.log("error: "+err);
		}
			timeline_end =res;
			getblockIDs();
	});
	
	// convert dates and get block ids
	var beginT = new Date(message.begintime);
    var endT = new Date(message.endtime);
	var begintime = beginT.getTime();
	var endtime = endT.getTime();
	
	var firstid;
	var lastid;
	var commands = [];
	
	function getblockIDs(){
		client.get("tb_time:"+begintime+":tb_id", function(err,res){
			if (err){
				console.log("error: "+err);
			}
			firstid = res;
			// if out of range
{'fraction_non_alphanumeric': 0.1933227344992051, 'fraction_numerical': 0.008267090620031796, 'mean_word_length': 3.730827067669173, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3288366', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1072, 'n_words': 220}