<commit_before>var http = require('http');
var UtmpParser = require('utmp');
var url = require('url');

http.createServer(function (req, res) {
	res.writeHead(200, {'Content-Type': 'application/json'});
  var reqUrl = url.parse(req.url, true, false);
  if (!reqUrl.query.user) {
    res.end();
    return;
  }

	var wtmpList = [];
  var p = new UtmpParser('/var/log/wtmp');
 	p.on('data', function(d) {
 	    if (d.user == reqUrl.query.user && d.type == "USER_PROCESS") {
 	      wtmpList.push(d);
 	    }
	});
	p.on('end', function() {
		res.end(JSON.stringify(wtmpList));
	});
	p.run();
}).listen(8088, "0.0.0.0");
console.log('Server running at 0.0.0.0:8088');<commit_msg>calculate minutes since login and return JSON<commit_after>var http = require('http');
var UtmpParser = require('utmp');
var url = require('url');

http.createServer(function (req, res) {
	res.writeHead(200, {'Content-Type': 'application/json'});
  	var reqUrl = url.parse(req.url, true, false);
  	if (!reqUrl.query.user) {
    		res.end();
    		return;
	}

	var wtmpList = [];
	var p = new UtmpParser('/var/log/wtmp');
 	p.on('data', function(d) {
 	    if (d.user == reqUrl.query.user && d.type == "USER_PROCESS") {
 	      wtmpList.push(d);
 	    }
	});
	p.on('end', function() {
		for (var i = 0; i < wtmpList.length; i++) {
			var record = new Object;
			record.user = wtmpList[i].user
			record.type = wtmpList[i].type;
			record.minutes = Math.round((new Date().getTime() - wtmpList[i].timestamp.getTime())/60000);
			res.write(JSON.stringify(record));
		}
		res.end('\n');
	});
	p.run();
}).listen(8088, "0.0.0.0");
console.log('Server running at 0.0.0.0:8088');
{'fraction_non_alphanumeric': 0.21250758955676988, 'fraction_numerical': 0.02671523982999393, 'mean_word_length': 3.565096952908587, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1913914', 'n_tokens_mistral': 679, 'n_tokens_neox': 636, 'n_words': 121}