<commit_before>/*
*
* Copyright (C) 2011, The Locker Project
* All rights reserved.
*
* Please see the LICENSE file for more information.
*
*/

var fs = require('fs')
  , request = require('request')
  , auth
  , seenIDs = {}
  , Badgess = []
  , lastBadges = {}
  , newBadges = []
  ;

exports.sync = function(processInfo, cb) {
    auth = processInfo.auth;
    if (processInfo.config && processInfo.config.Badgess) {
        lastBadges = processInfo.config.Badgess;
    }
    exports.syncBadges(function(err) {
        var responseObj = {data : {}, config : {}};
        responseObj.data.Badges = newBadges;
        responseObj.config.Badges = seenIDs;
        cb(err, responseObj);
    });
};


exports.syncBadges = function (callback) {
    getBadges(auth.accessToken, function(err, resp, data) {
        if(err || !data || !JSON.parse(data).response.badges) return callback("broke" + err);
        var badges = JSON.parse(data).response.badges;
        if (badges === undefined) {
            return callback('error attempting to get profile data - ' + data);
        }
        if (!badges || badges.length == 0) {
            return callback();
        }
        badges = JSON.stringify(badges);
        for(var i = 0; i < badges.length; i++) {
            if (lastBadges[badges[i].id]) break;
            newBadges.push({obj: badges[i], timestamp: Date.now()});
            seenIDs[badges[i].id] = true;
        }
        callback();
    });
}

function getBadges(token, callback) {
    request.get({uri:'https://api.foursquare.com/v2/users/self/badges?oauth_token=' + token}, callback);
}
<commit_msg>removed stray variable<commit_after>/*
*
* Copyright (C) 2011, The Locker Project
* All rights reserved.
*
* Please see the LICENSE file for more information.
*
*/

var fs = require('fs')
  , request = require('request')
  , auth
  , seenIDs = {}
  , lastBadges = {}
  , newBadges = []
  ;

exports.sync = function(processInfo, cb) {
    auth = processInfo.auth;
    if (processInfo.config && processInfo.config.Badgess) {
        lastBadges = processInfo.config.Badgess;
    }
    exports.syncBadges(function(err) {
        var responseObj = {data : {}, config : {}};
        responseObj.data.Badges = newBadges;
        responseObj.config.Badges = seenIDs;
        cb(err, responseObj);
    });
};


exports.syncBadges = function (callback) {
    getBadges(auth.accessToken, function(err, resp, data) {
        if(err || !data || !JSON.parse(data).response.badges) return callback("broke" + err);
        var badges = JSON.parse(data).response.badges;
        if (badges === undefined) {
            return callback('error attempting to get profile data - ' + data);
        }
        if (!badges || badges.length == 0) {
            return callback();
        }
        for(var i = 0; i < badges.length; i++) {
            console.log(badges[i]);
            if (lastBadges[badges[i].id]) break;
            newBadges.push({obj: badges[i], timestamp: Date.now()});
            seenIDs[badges[i].id] = true;
        }
        callback();
    });
}

function getBadges(token, callback) {
    request.get({uri:'https://api.foursquare.com/v2/users/self/badges?oauth_token=' + token}, callback);
}

{'fraction_non_alphanumeric': 0.153198127925117, 'fraction_numerical': 0.00436817472698908, 'mean_word_length': 2.5901455767077266, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1760082', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1020, 'n_words': 212}