<commit_before>'use strict';

angular.module('stockApp')
  .controller('MainCtrl', function ($scope, StockData) {

    $scope.stockSymbols = [
      'YHOO',
      'MSFT',
      'KO'
    ];

    angular.forEach($scope.stockSymbols, function (value) {

      StockData.get(value, '2013-09-01', '2014-03-31').then(function (data) {

        var serie = {
          name: value,
          data: data,
          tooltip: {
            valueDecimals: 2
          }
        };

        $scope.chartConfig.series.push(serie);
        $scope.chartConfig.loading = false;

      });

    });

    $scope.chartConfig = {
      options: {
        chart: {
          type: 'line',
          zoomType: 'x'
        }
      },

      rangeSelector: {
        selected: 1
      },

      title: {
        text: 'Stock Data'
      },

      series: [],

      useHighStocks: true,
      loading: true
    };

  });
<commit_msg>Improve promise resolving<commit_after>'use strict';

angular.module('stockApp')
  .controller('MainCtrl', function ($scope, $q, StockData) {

    var promises = [];

    $scope.stockSymbols = [
      'YHOO',
      'MSFT',
      'KO'
    ];

    // get data for all symbols in stockSymbols[]
    angular.forEach($scope.stockSymbols, function (value, key) {

      promises[key] = StockData.get(value, '2013-09-01', '2014-03-31').then(function (data) {

        var serie = {
          name: value,
          data: data,
          tooltip: {
            valueDecimals: 2
          }
        };

        $scope.chartConfig.series.push(serie);

      });

    });

    // wait until all promises are resolved
    $q.all(promises).then(function () {
      $scope.chartConfig.loading = false;
    });

    // highcharts/highstock config
    $scope.chartConfig = {
      options: {
        chart: {
          type: 'line',
          zoomType: 'x'
        }
      },

      rangeSelector: {
        selected: 1
      },

      title: {
        text: 'Stock Data'
      },

      series: [],

      useHighStocks: true,
      loading: true
    };

  });

{'fraction_non_alphanumeric': 0.14452554744525548, 'fraction_numerical': 0.017518248175182483, 'mean_word_length': 1.6494845360824741, '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': '4914953', 'n_tokens_mistral': 688, 'n_tokens_neox': 629, 'n_words': 121}