<commit_before>'use strict';

angular.module('homepageApp')
  .service('Google', function Google($http, $location, Storage) {

    var client_id = "165163675817.apps.googleusercontent.com";

    function gcall(path, token) {
      return $http.jsonp("https://www.googleapis.com/" + path + "?callback=JSON_CALLBACK&alt=json&access_token=" + token);
    }

    function getAccounts() {
      return Storage.get("google_accounts") || {};
    }

    function setAccount(account) {
      var accounts = getAccounts();
      if (accounts[account.user_id]) {
        for (var prop in account) {
          accounts[account.user_id][prop] = account[prop];
        }
      } else {
        accounts[account.user_id] = account;
      }

      Storage.set("google_accounts", accounts);
    }

    function getPartialAccount(token, tokeninfo) {
      var expires = new Date();
      expires.setTime(expires.getTime() + (tokeninfo.expires_in - 60) * 1000); // 60s buffer

      return {
        user_id: tokeninfo.user_id,
        expires: expires,
        access_token: token
      };
    }

    function getFullAccount(token, tokeninfo) {
      var expires = new Date();
      expires.setTime(expires.getTime() + (tokeninfo.expires_in - 60) * 1000); // 60s buffer

      return gcall("userinfo/email", token)
        .then(function(response) {
          return {
            user_id: tokeninfo.user_id,
            expires: expires,
            email: response.data.data.email,
            access_token: token
          }
        });<commit_msg>Small change in Google service so it's a bit DRYer<commit_after>'use strict';

angular.module('homepageApp')
  .service('Google', function Google($http, $location, Storage) {

    var client_id = "165163675817.apps.googleusercontent.com";

    function gcall(path, token) {
      return $http.jsonp("https://www.googleapis.com/" + path + "?callback=JSON_CALLBACK&alt=json&access_token=" + token);
    }

    function getAccounts() {
      return Storage.get("google_accounts") || {};
    }

    function setAccount(account) {
      var accounts = getAccounts();
      if (accounts[account.user_id]) {
        for (var prop in account) {
          accounts[account.user_id][prop] = account[prop];
        }
      } else {
        accounts[account.user_id] = account;
      }

      Storage.set("google_accounts", accounts);
    }

    function getPartialAccount(token, tokeninfo) {
      var expires = new Date();
      expires.setTime(expires.getTime() + (tokeninfo.expires_in - 60) * 1000); // 60s buffer

      return {
        user_id: tokeninfo.user_id,
        expires: expires,
        access_token: token
      };
    }

    function getFullAccount(token, tokeninfo) {
      var account = getPartialAccount(token, tokeninfo);

      return gcall("userinfo/email", token)
        .then(function(response) {
          account.email = response.data.data.email;
          return account;
        });
{'fraction_non_alphanumeric': 0.1284497444633731, 'fraction_numerical': 0.016354344122657582, 'mean_word_length': 2.5980392156862746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5604358', 'n_tokens_mistral': 936, 'n_tokens_neox': 874, 'n_words': 174}