<commit_before>/**
 * Index Route.
 *
 * @module routes/index
 */
import Ember from 'ember';

let topRouteHandler = function(store) {
  return new Ember.RSVP.Promise(function(resolve) {
    var topTrends = Ember.A();
    store.query('daily-ridership', {'high-ridership': 'all'})
         .then(function(dailyRiderships) {
           dailyRiderships.forEach(function(dailyRidership) {
             dailyRidership.get('route').then(function(route) {
               let routeNumber = route.get('routeNumber').toString();
               let routeCompendium = topTrends.findBy('routeNumber', routeNumber);
               if (routeCompendium) {
                 routeCompendium.riderships.pushObject(dailyRidership);
                 routeCompendium.riderships = routeCompendium.riderships.sortBy('measurementTimestamp');
               } else {
                 let riderships = Ember.A();
                 riderships.pushObject(dailyRidership);
                 let selector = 'top-route-viz-' + routeNumber;
                 let routeCompendium = {
                   'routeNumber': routeNumber,
                   'routeName': route.get('routeName'),
                   'selector': selector,
                   'riderships': riderships
                 }
                 topTrends.pushObject(routeCompendium);
               }});});})
         .finally(function() {
           resolve(topTrends);
         });
  })
}

/**
 * Exports extension of Ember's Route class.
 */
export default Ember.Route.extend({
  /**
   * The model for the route. The function queries for
   * *all* `system-trend` records and high ridership `daily-ridership` models.
   */
  model() {
    return Ember.RSVP.hash({
      trends: this.store.findAll('system-trend'),
      topRoutes: topRouteHandler(this.store)
    });
  }
});<commit_msg>Clean chart libary when activating index.<commit_after>/**
 * Index Route.
 *
 * @module routes/index
 */
import Ember from 'ember';

let topRouteHandler = function(store) {
  return new Ember.RSVP.Promise(function(resolve) {
    var topTrends = Ember.A();
    store.query('daily-ridership', {'high-ridership': 'all'})
         .then(function(dailyRiderships) {
           dailyRiderships.forEach(function(dailyRidership) {
             dailyRidership.get('route').then(function(route) {
               let routeNumber = route.get('routeNumber').toString();
               let routeCompendium = topTrends.findBy('routeNumber', routeNumber);
               if (routeCompendium) {
                 routeCompendium.riderships.pushObject(dailyRidership);
                 routeCompendium.riderships = routeCompendium.riderships.sortBy('measurementTimestamp');
               } else {
                 let riderships = Ember.A();
                 riderships.pushObject(dailyRidership);
                 let selector = 'top-route-viz-' + routeNumber;
                 let routeCompendium = {
                   'routeNumber': routeNumber,
                   'routeName': route.get('routeName'),
                   'selector': selector,
                   'riderships': riderships
                 }
                 topTrends.pushObject(routeCompendium);}});});})
         .finally(function() {
           resolve(topTrends);
         });})
}

/**
 * Exports extension of Ember's Route class.
 */
export default Ember.Route.extend({
  activate: function(){
    this._super();
    nv.charts = {};
    nv.graphs = [];
    nv.logs = {};
    // and remove listeers for onresize.
    window.onresize = null;
  },
  /**
   * The model for the route. The function queries for
   * *all* `system-trend` records and high ridership `daily-ridership` models.
   */
  model() {
    return Ember.RSVP.hash({
      services: this.store.peekAll('route'),
      trends: this.store.peekAll('system-trend'),
      topRoutes: topRouteHandler(this.store)
    });
  }
});
{'fraction_non_alphanumeric': 0.12801243845555843, 'fraction_numerical': 0.0, 'mean_word_length': 2.174342105263158, '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': '4183369', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1090, 'n_words': 202}