<commit_before>angular.module('mnSettingsNotificationsService', [
  'mnHttp',
  'mnPoolDefault',
  'mnBucketsService',
  'mnPools'
]).factory('mnSettingsNotificationsService',
  function (mnHttp, mnPoolDefault, mnBucketsService, mnPools, $q, $window, $rootScope) {
    var mnSettingsNotificationsService = {};

    function buildPhoneHomeThingy(infos) {
      var buckets = infos[1];
      var poolsDefault = infos[0];
      var pools = infos[2];

      return {
        version: pools.implementationVersion,
        componentsVersion: pools.componentsVersion,
        uuid: pools.uuid,
        numNodes: poolsDefault.nodes.length,
        ram: {
          total: poolsDefault.storageTotals.ram.total,
          quotaTotal: poolsDefault.storageTotals.ram.quotaTotal,
          quotaUsed: poolsDefault.storageTotals.ram.quotaUsed
        },
        hdd: {
          total: poolsDefault.storageTotals.hdd.total,
          quotaTotal: poolsDefault.storageTotals.hdd.quotaTotal,
          used: poolsDefault.storageTotals.hdd.used,
          usedByData: poolsDefault.storageTotals.hdd.usedByData
        },
        buckets: {
          total: buckets.length,
          membase: buckets.byType.membase.length,
          memcached: buckets.byType.memcached.length
        },
        counters: poolsDefault.counters,
        nodes: {
          os: _.pluck(poolsDefault.nodes, 'os'),
          uptime: _.pluck(poolsDefault.nodes, 'uptime'),
          istats: _.pluck(poolsDefault.nodes, 'interestingStats')
        },
        browser: $window.navigator.userAgent
      };
    }

    mnSettingsNotificationsService.buildPhoneHomeThingy = function () {
      return $q.all([
        mnPoolDefault.getFresh(),
        mnBucketsService.getBucketsByType(),
        mnPools.get()
      ]).then(buildPhoneHomeThingy);
    };

    mnSettingsNotificationsService.getUpdates = function (data) {
      return mnHttp({
        method: 'JSONP',
        url: 'http://ph.couchbase.net/v2',
        params: {launchID: data.launchID, version: data.version, callback: 'JSON_CALLBACK'}
      });
    };

    mnSettingsNotificationsService.maybeCheckUpdates = function () {
      return mnSettingsNotificationsService.getSendStatsFlag().then(function (sendStatsData) {
        if (!sendStatsData.sendStats) {
          return sendStatsData;
        } else {
          return mnPools.get().then(function (pools) {
            return mnSettingsNotificationsService.getUpdates({
              launchID: pools.launchID,
              version: pools.version
            }).then(function (resp) {<commit_msg>MB-12222: eight second timeout for ph.couchbase.net<commit_after>angular.module('mnSettingsNotificationsService', [
  'mnHttp',
  'mnPoolDefault',
  'mnBucketsService',
  'mnPools'
]).factory('mnSettingsNotificationsService',
  function (mnHttp, mnPoolDefault, mnBucketsService, mnPools, $q, $window, $rootScope) {
    var mnSettingsNotificationsService = {};

    function buildPhoneHomeThingy(infos) {
      var buckets = infos[1];
      var poolsDefault = infos[0];
      var pools = infos[2];

      return {
        version: pools.implementationVersion,
        componentsVersion: pools.componentsVersion,
        uuid: pools.uuid,
        numNodes: poolsDefault.nodes.length,
        ram: {
          total: poolsDefault.storageTotals.ram.total,
          quotaTotal: poolsDefault.storageTotals.ram.quotaTotal,
          quotaUsed: poolsDefault.storageTotals.ram.quotaUsed
        },
        hdd: {
          total: poolsDefault.storageTotals.hdd.total,
          quotaTotal: poolsDefault.storageTotals.hdd.quotaTotal,
          used: poolsDefault.storageTotals.hdd.used,
          usedByData: poolsDefault.storageTotals.hdd.usedByData
        },
        buckets: {
          total: buckets.length,
          membase: buckets.byType.membase.length,
          memcached: buckets.byType.memcached.length
        },
        counters: poolsDefault.counters,
        nodes: {
          os: _.pluck(poolsDefault.nodes, 'os'),
          uptime: _.pluck(poolsDefault.nodes, 'uptime'),
          istats: _.pluck(poolsDefault.nodes, 'interestingStats')
        },
        browser: $window.navigator.userAgent
      };
    }

    mnSettingsNotificationsService.buildPhoneHomeThingy = function () {
      return $q.all([
        mnPoolDefault.getFresh(),
        mnBucketsService.getBucketsByType(),
        mnPools.get()
      ]).then(buildPhoneHomeThingy);
    };

    mnSettingsNotificationsService.getUpdates = function (data) {
      return mnHttp({
        method: 'JSONP',
        url: 'http://ph.couchbase.net/v2',
        timeout: 8000,
        params: {launchID: data.launchID, version: data.version, callback: 'JSON_CALLBACK'}
      });
    };

    mnSettingsNotificationsService.maybeCheckUpdates = function () {
      return mnSettingsNotificationsService.getSendStatsFlag().then(function (sendStatsData) {
        if (!sendStatsData.sendStats) {
          return sendStatsData;
        } else {
          return mnPools.get().then(function (pools) {
            return mnSettingsNotificationsService.getUpdates({
              launchID: pools.launchID,
              version: pools.version
            }).then(function (resp) {
{'fraction_non_alphanumeric': 0.10827414090996353, 'fraction_numerical': 0.003263582261470532, 'mean_word_length': 2.6408106219426974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '4049835', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1511, 'n_words': 243}