<commit_before>var Client = require('node-rest-client').Client;
var client = new Client();

// Keys are stringified userId-questionId pairs
// Values are the last activity time
var watcher = {};

var url = 'https://api.stackexchange.com/2.2/';
var questionAnswerUrlAppend = '?site=stackoverflow';

function getLastActivityTime(questionId) {
	var questionUrl = url + '/questions/' + questionId + questionAnswerUrlAppend;

	console.log(questionUrl);

	var lastActivityDate = 0;

    client.get(questionUrl, function (data, response) {
    	lastActivityDate = data.items[0].last_activity_date;
        console.log("Last Activity Date - " + lastActivityDate); 
    });

    return lastActivityDate;
}

function checkForUpdates(callback) {
	console.log("Checking for updates");
	
	console.log(watcher);

	for(toWatchObj in watcher) {
		currentTime = watcher[toWatchObj];
	
		console.log(toWatchObj);

		var questionId = toWatchObj.split(",")[1];
		var userId = toWatchObj.split(",")[0];

		console.log("Question id: " + questionId);

		var newTime = getLastActivityTime(questionId);

		console.log("Current known last activity time: " + currentTime);

		if (newTime + 10 > currentTime){
			console.log("Sending message to bot")
			event = {'userId': userId}
			callback(userId, questionId);
			watcher[questionId] =  newTime;
		}
	}
}

module.exports = {

	getWatchList: function(userId){
		console.log("Inside getWatchList");
		var map = {};
		for(toWatchObj in watcher) {<commit_msg>Fix mocking in watcher<commit_after>var Client = require('node-rest-client').Client;
var client = new Client();

// Keys are stringified userId-questionId pairs
// Values are the last activity time
var watcher = {};

var url = 'https://api.stackexchange.com/2.2/';
var questionAnswerUrlAppend = '?site=stackoverflow';

function getLastActivityTime(questionId) {
	var questionUrl = url + '/questions/' + questionId + questionAnswerUrlAppend;

	console.log(questionUrl);

	var lastActivityDate = 0;

    client.get(questionUrl, function (data, response) {
    	lastActivityDate = data.items[0].last_activity_date;
        console.log("Last Activity Date - " + lastActivityDate); 
    });

    return lastActivityDate;
}

function checkForUpdates(callback) {
	console.log("Checking for updates");
	
	console.log(watcher);

	for(toWatchObj in watcher) {
		currentTime = watcher[toWatchObj];
	
		console.log(toWatchObj);

		var questionId = toWatchObj.split(",")[1];
		var userId = toWatchObj.split(",")[0];

		console.log("Question id: " + questionId);

		var newTime = getLastActivityTime(questionId);

		console.log("Current known last activity time: " + currentTime);

		if (newTime > currentTime){
			console.log("Sending message to bot")
			event = {'userId': userId}
			callback(userId, questionId);
			watcher[questionId] =  newTime;
		}
	}
}

module.exports = {

	getWatchList: function(userId){
		console.log("Inside getWatchList");
		var map = {};
		for(toWatchObj in watcher) {
{'fraction_non_alphanumeric': 0.13326585695006748, 'fraction_numerical': 0.004723346828609987, 'mean_word_length': 4.450367647058823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '164264', 'n_tokens_mistral': 1000, 'n_tokens_neox': 924, 'n_words': 212}