<commit_before>import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import Ember from 'ember';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
  editTitle: null,
  hideNewButton: false,
  modelName: null,
  newTitle: null,

  _createNewRecord(params) {
    return new Ember.RSVP.Promise(function(resolve) {
      this.generateId().then(function(newId) {
        this.getNewData(params).then(function(data) {
          let modelName = this.get('modelName');
          if (newId) {
            data.id = newId;
          }
          if (newId && this.store.hasRecordForId(modelName, newId)) {
            resolve(this.store.push(this.store.normalize(modelName, data)));
          } else {
            resolve(this.store.createRecord(modelName, data));
          }
        }.bind(this));
      }.bind(this));
    }.bind(this));
  },

  idParam: function() {
    let modelName = this.get('modelName');
    return `${modelName}_id`;
  }.property('modelName'),

  /**
   * Override this function to generate an id for a new record
   * @return a promise that will resolved to a generated id;default is null which means that an
   * id will be automatically generated via Ember data.
   */
  generateId() {
    return Ember.RSVP.resolve(null);
  },

  /**
   * Override this function to define what data a new model should be instantiated with.
   * @return a promise that will resolve with the data for a new record; defaults to empty object.
   */
  getNewData() {
    return Ember.RSVP.resolve({});
  },

  getScreenTitle(model) {
    if (model.get('isNew')) {
      return this.get('newTitle');
    } else {
      return this.get('editTitle');
    }
  },

  model(params) {
    let idParam = this.get('idParam');
    if (!Ember.isEmpty(idParam) && params[idParam] === 'new') {
      return this._createNewRecord(params);
    } else {
      return this._super(params);
    }
  },

  setupController(controller, model) {
    let sectionDetails = {};
    sectionDetails.currentScreenTitle = this.getScreenTitle(model);
    if (this.get('hideNewButton')) {
      sectionDetails.newButtonAction = null;
    }
    this.send('setSectionHeader', sectionDetails);
    this._super(controller, model);
  }
});<commit_msg>Fix for load db screen not loading.<commit_after>import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import Ember from 'ember';

const { get } = Ember;

export default Ember.Route.extend(AuthenticatedRouteMixin, {
  editTitle: null,
  hideNewButton: false,
  modelName: null,
  newTitle: null,

  _createNewRecord(params) {
    return new Ember.RSVP.Promise(function(resolve) {
      this.generateId().then(function(newId) {
        this.getNewData(params).then(function(data) {
          let modelName = get(this, 'modelName');
          if (newId) {
            data.id = newId;
          }
          if (newId && this.store.hasRecordForId(modelName, newId)) {
            resolve(this.store.push(this.store.normalize(modelName, data)));
          } else {
            resolve(this.store.createRecord(modelName, data));
          }
        }.bind(this));
      }.bind(this));
    }.bind(this));
  },

  idParam: function() {
    let modelName = get(this, 'modelName');
    return `${modelName}_id`;
  }.property('modelName'),

  /**
   * Override this function to generate an id for a new record
   * @return a promise that will resolved to a generated id;default is null which means that an
   * id will be automatically generated via Ember data.
   */
  generateId() {
    return Ember.RSVP.resolve(null);
  },

  /**
   * Override this function to define what data a new model should be instantiated with.
   * @return a promise that will resolve with the data for a new record; defaults to empty object.
   */
  getNewData() {
    return Ember.RSVP.resolve({});
  },

  getScreenTitle(model) {
    if (get(model, 'isNew')) {
      return get(this, 'newTitle');
    } else {
      return get(this, 'editTitle');
    }
  },

  model(params) {
    let idParam = get(this, 'idParam');
    if (!Ember.isEmpty(idParam) && params[idParam] === 'new') {
      return this._createNewRecord(params);
    } else {
      return this._super(params);
    }
  },

  setupController(controller, model) {
    let sectionDetails = {};
    sectionDetails.currentScreenTitle = this.getScreenTitle(model);
    if (get(this, 'hideNewButton')) {
      sectionDetails.newButtonAction = null;
    }
    this.send('setSectionHeader', sectionDetails);
    this._super(controller, model);
  }
});
{'fraction_non_alphanumeric': 0.13112959719789843, 'fraction_numerical': 0.0, 'mean_word_length': 3.000875656742557, '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': '4101914', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1380, 'n_words': 334}