<commit_before>import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import RSVP from 'rsvp';
const { all } = RSVP;

export default  Route.extend({
  store: service(),
  /**
   * Prefetch related data to limit network requests
  */
  afterModel(model) {
    const store = this.get('store');
    const courses = [model.get('id')];
    const course = model.get('id');
    const sessions = model.hasMany('sessions').ids();
    const existingSessionsInStore = store.peekAll('session');
    const existingSessionIds = existingSessionsInStore.mapBy('id');
    const unloadedSessions = sessions.filter(id => !existingSessionIds.includes(id));

    //if we have already loaded all of these sessions we can just proceed normally
    if (unloadedSessions.length === 0) {
      return;
    }

    return all([
      store.query('session', {filters: {course}}),
      store.query('offering', {filters: {courses}}),
      store.query('ilm-session', {filters: {courses}}),
      store.query('objective', {filters: {courses}}),
      store.query('objective', {filters: {sessions}}),
      store.query('session-type', {filters: {sessions}}),
    ]);
  },
  queryParams: {
    sortSessionsBy: {
      replace: true
    },
    filterSessionsBy: {<commit_msg>Limit the length of the URL when we pre-load data<commit_after>import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import RSVP from 'rsvp';
const { all } = RSVP;

export default  Route.extend({
  store: service(),
  /**
   * Prefetch related data to limit network requests
  */
  afterModel(model) {
    const store = this.get('store');
    const courses = [model.get('id')];
    const course = model.get('id');
    const sessions = model.hasMany('sessions').ids();
    const existingSessionsInStore = store.peekAll('session');
    const existingSessionIds = existingSessionsInStore.mapBy('id');
    const unloadedSessions = sessions.filter(id => !existingSessionIds.includes(id));

    //if we have already loaded all of these sessions we can just proceed normally
    if (unloadedSessions.length === 0) {
      return;
    }

    let promises = [
      store.query('session', { filters: { course } }),
      store.query('offering', { filters: { courses } }),
      store.query('ilm-session', { filters: { courses } }),
      store.query('objective', { filters: { courses } }),
    ];
    const maximumSessionLoad = 100;
    if (sessions.length < maximumSessionLoad) {
      promises.pushObject(store.query('objective', { filters: { sessions } }));
      promises.pushObject(store.query('session-type', { filters: { sessions } }));
    } else {
      for (let i = 0; i < sessions.length; i += maximumSessionLoad) {
        let slice = sessions.slice(i, i + maximumSessionLoad);
        promises.pushObject(store.query('objective', { filters: { sessions: slice } }));
        promises.pushObject(store.query('session-type', { filters: { sessions: slice } }));
      }
    }

    return all(promises);
  },
  queryParams: {
    sortSessionsBy: {
      replace: true
    },
    filterSessionsBy: {
{'fraction_non_alphanumeric': 0.14950272698107153, 'fraction_numerical': 0.0019249278152069298, 'mean_word_length': 3.44793152639087, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6057954', 'n_tokens_mistral': 921, 'n_tokens_neox': 917, 'n_words': 229}