<commit_before>/**
 *
 */
App.ProductsController = Ember.ArrayController.extend(
{
  needs: ['user', 'application', 'product', 'products', 'products.show', 'action', 'program'],

  page: 1,
  perPage: 24,
  lastPage: false,
  keywords: false,
  loadingMore: false,
  currentCategory: null,
  currentProduct: null,
  category: '',
  categories: null,
  special_categories: Ember.ArrayProxy.create({ content: [] }), // reserved for special campaign categories
  categoryMap: Ember.ArrayProxy.create({ content: [] }),

  actions:
  {
    loadProduct: function(id)
    {
      this.get('controllers.user').send('healthCheck');
      this.get('controllers.products').set('keywords', false);
      this.transitionToRoute('products.show', id);
    },
    loadProducts: function(cat)
    {
      this.get('controllers.user').send('healthCheck');
      this.get('controllers.products').set('page', 1);
      this.get('controllers.products').set('lastPage', false);
      this.get('controllers.products').set('keywords', false);
      this.transitionToRoute('products', cat.get('urlName'));
    },
    loadCategories: function()
    {
      console.log('loadCategories')

      var transition = this.get('controllers.application').get('previousTransition');

      //~ if (transition)
      //~ {
        //~ console.log(transition.params);
        //~ console.log('===========================================================');
      //~ }
      var category = null;
      var self = this;

      var controller = self.get('controllers.products');

      if (controller.get('categoryMap').content.length > 0)
      {
        // nothing to do anymore, we got the cats meanwhile
        return;
      }

      if (transition && transition.params)
      {
        category = transition.params.category;
      }

      // load categories
      controller.set('categories', this.store.find('category', { display: 'tree', filter: 'all', personal: App.personalizedContent, maxlevel: 1 }));
      // map out categories
      controller.get('categories').then(function(data)
      {
        controller.get('categoryMap').set('content', []);

        data.content.forEach(function(item, index, enumerable)
        {
          controller.get('categoryMap').pushObject(item);

          if (item.get('selector') == 'x')
          {
            controller.get('special_categories').pushObject(item);
          }

          if (category && item.get('urlName') == category)
          {
            controller.set('currentCategory', item);
          }
          item.get('subcategories').forEach(function(_item, _index, _enum)
          {
            controller.get('categoryMap').pushObject(_item);
            if (category && _item.get('urlName') == category)
            {
              controller.set('currentCategory', _item);
            }
          }, item);
        });<commit_msg>safety<commit_after>/**
 *
 */
App.ProductsController = Ember.ArrayController.extend(
{
  needs: ['user', 'application', 'product', 'products', 'products.show', 'action', 'program'],

  page: 1,
  perPage: 24,
  lastPage: false,
  keywords: false,
  loadingMore: false,
  currentCategory: null,
  currentProduct: null,
  category: '',
  categories: null,
  special_categories: Ember.ArrayProxy.create({ content: [] }), // reserved for special campaign categories
  categoryMap: Ember.ArrayProxy.create({ content: [] }),

  actions:
  {
    loadProduct: function(id)
    {
      this.get('controllers.user').send('healthCheck');
      this.get('controllers.products').set('keywords', false);
      this.transitionToRoute('products.show', id);
    },
    loadProducts: function(cat)
    {
      this.get('controllers.user').send('healthCheck');
      this.get('controllers.products').set('page', 1);
      this.get('controllers.products').set('lastPage', false);
      this.get('controllers.products').set('keywords', false);
      this.transitionToRoute('products', cat.get('urlName'));
    },
    loadCategories: function()
    {
      console.log('loadCategories')

      var transition = this.get('controllers.application').get('previousTransition');

      //~ if (transition)
      //~ {
        //~ console.log(transition.params);
        //~ console.log('===========================================================');
      //~ }
      var category = null;
      var self = this;

      var controller = self.get('controllers.products');

      if (controller.get('categoryMap').content.length > 0)
      {
        // nothing to do anymore, we got the cats meanwhile
        return;
      }

      if (transition && transition.params)
      {
        category = transition.params.category;
      }

      // load categories
      controller.set('categories', this.store.find('category', { display: 'tree', filter: 'all', personal: App.personalizedContent, maxlevel: 1 }));
      // map out categories
      controller.get('categories').then(function(data)
      {
        controller.get('categoryMap').set('content', []);

        data.content.forEach(function(item, index, enumerable)
        {
          controller.get('categoryMap').pushObject(item);

          if (item.get('selector') == 'x')
          {
            if (! controller.get('special_categories').findBy('urlName', item.get('urlName')))
            {
              controller.get('special_categories').pushObject(item);
            }
          }

          if (category && item.get('urlName') == category)
          {
            controller.set('currentCategory', item);
          }
          item.get('subcategories').forEach(function(_item, _index, _enum)
          {
            controller.get('categoryMap').pushObject(_item);
            if (category && _item.get('urlName') == category)
            {
              controller.set('currentCategory', _item);
            }
          }, item);
        });
{'fraction_non_alphanumeric': 0.17704413274033526, 'fraction_numerical': 0.0020526855969893944, 'mean_word_length': 2.6681304893350064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4792721', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1565, 'n_words': 277}