<commit_before>"use strict";
/**
 *
 */
App.ApplicationController = Ember.ArrayController.extend(
{
  needs: ['user', 'application', 'category', 'products', 'pairing',
          'action', 'program', 'sync'],

  glomeid: false,
  password: '',
  loggedin: false,
  inProgress: false,
  notification: false,
  token: false,

  actions:
  {
    /**
     * should be called from the application route before model
     */
    connect: function()
    {
      console.log('here we start?');
      if (! window.localStorage.getItem('loggedin'))
      {
        window.localStorage.setItem('loggedin', false);
      }

      if (window.localStorage.getItem('glomeid') && typeof window.localStorage.getItem('glomeid') != 'undefined')
      {
        console.log('glomeid exists: ' + window.localStorage.getItem('glomeid'));
        this.set('glomeid', window.localStorage.getItem('glomeid'));
        console.log('lets login');
        this.get('controllers.user').send('auth', this.get('glomeid'), this.get('password'));
      }
      else
      {
        if (App.apiKey)
        {
          this.send('generateGlomeId');
        }
        else
        {
          console.log('It is not a Glome enabled application.');
        }
      }
    },
    loadCategories: function(category)
    {
      var self = this;
      var controller = this.get('controllers.products');
      // load categories
      controller.set('categories', this.store.find('category', { display: 'tree', filter: 'all', maxlevel: 1 }));
      // map out categories
      controller.get('categories').then(function(data)
      {
        data.content.forEach(function(item, index, enumerable)
        {
          controller.get('categoryMap')[item.get('urlName')] = item;
          item.get('subcategories').forEach(function(_item, _index, _enum)
          {
            controller.get('categoryMap')[_item.get('urlName')] = _item;
          }, item);
        });

        console.log('category: ' + category);
        if (category)
        {
          controller.set('currentCategory', controller.get('categoryMap')[category]);
        }

        console.log('loaded categories');

        var prevT = self.get('controllers.application').get('previousTransition');<commit_msg>use the enumerable array properly<commit_after>"use strict";
/**
 *
 */
App.ApplicationController = Ember.ArrayController.extend(
{
  needs: ['user', 'application', 'category', 'products', 'pairing',
          'action', 'program', 'sync'],

  glomeid: false,
  password: '',
  loggedin: false,
  inProgress: false,
  notification: false,
  token: false,

  actions:
  {
    /**
     * should be called from the application route before model
     */
    connect: function()
    {
      console.log('here we start?');
      if (! window.localStorage.getItem('loggedin'))
      {
        window.localStorage.setItem('loggedin', false);
      }

      if (window.localStorage.getItem('glomeid') && typeof window.localStorage.getItem('glomeid') != 'undefined')
      {
        console.log('glomeid exists: ' + window.localStorage.getItem('glomeid'));
        this.set('glomeid', window.localStorage.getItem('glomeid'));
        console.log('lets login');
        this.get('controllers.user').send('auth', this.get('glomeid'), this.get('password'));
      }
      else
      {
        if (App.apiKey)
        {
          this.send('generateGlomeId');
        }
        else
        {
          console.log('It is not a Glome enabled application.');
        }
      }
    },
    loadCategories: function(category)
    {
      var self = this;
      var controller = this.get('controllers.products');
      // load categories
      controller.set('categories', this.store.find('category', { display: 'tree', filter: 'all', maxlevel: 1 }));
      // map out categories
      controller.get('categories').then(function(data)
      {
        data.content.forEach(function(item, index, enumerable)
        {
          controller.get('categoryMap').pushObject(item);
          item.get('subcategories').forEach(function(_item, _index, _enum)
          {
            controller.get('categoryMap').pushObject(_item);
          }, item);
        });

        controller.get('categoryMap').forEach(
          function(item, index, enumerable)
          {
            // fetch all programs who have content in this category
            var vars =
            {
              catid: item.get('id'),
              application:
              {
                master_uid: App.apiHost,
                master_apikey: App.apiKey
              }
            };

            controller.get('categoryMap').objectAt(index)['programs'] = self.store.find('program', vars);
          });

        if (category)
        {
          controller.set('currentCategory', controller.get('categoryMap').findBy('urlName', category));
        }

        console.log('loaded categories');

        var prevT = self.get('controllers.application').get('previousTransition');
{'fraction_non_alphanumeric': 0.15067390867028768, 'fraction_numerical': 0.0004023335345001006, 'mean_word_length': 2.348148148148148, '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': '6174947', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1378, 'n_words': 253}