<commit_before>import Ember from 'ember';
import ENV from '../../config/environment';

export default Ember.Route.extend({

  queryParams: {
    q: {
      refreshModel: true
    },

    page: {
      refreshModel: true
    }
  },

  beforeModel() {
    this.controllerFor('home').set('activeTab', 'search');
  },

  model(params) {
    const { q, page } = params;
    if (!q) {
      return null;
    }

    const limit = ENV.NUM_SONGS_PER_PAGE;
    const offset = (page - 1) * limit;

    this.controller.set('isSearching', true);
    return this.get('store').query('track', {
      tracksFrom: 'search',
      q: q,
      limit: limit,
      offset: offset
    }).then((result) => {
      this.controller.set('isSearching', false);
      return result;
    });
  }

});
<commit_msg>Fix issue resulting in early access of controller in search route<commit_after>import Ember from 'ember';
import ENV from '../../config/environment';

export default Ember.Route.extend({

  queryParams: {
    q: {
      refreshModel: true
    },

    page: {
      refreshModel: true
    }
  },

  beforeModel() {
    this.controllerFor('home').set('activeTab', 'search');
  },

  model(params) {
    const { q, page } = params;
    if (!q) {
      return null;
    }

    const limit = ENV.NUM_SONGS_PER_PAGE;
    const offset = (page - 1) * limit;

    if (this.controller) {
      this.controller.set('isSearching', true);
    }
    return this.get('store').query('track', {
      tracksFrom: 'search',
      q: q,
      limit: limit,
      offset: offset
    }).then((result) => {
      if (this.controller) {
        this.controller.set('isSearching', false);
      }

      return result;
    });
  }

});

{'fraction_non_alphanumeric': 0.1567472009428403, 'fraction_numerical': 0.0011785503830288745, 'mean_word_length': 2.369047619047619, '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': '3932881', 'n_tokens_mistral': 556, 'n_tokens_neox': 542, 'n_words': 124}