<commit_before>import Ember from 'ember';
import DS from 'ember-data';
export default Ember.Component.extend(Ember.I18n.TranslateableProperties, {
  subject: null,
  isCourse: false,
  isSession: Ember.computed.not('isCourse'),
  materials: Ember.computed.alias('subject.learningMaterials'),
  newLearningMaterials: [],
  classNames: ['detail-learning-materials'],
  newButtonTitleTranslation: 'general.add',
  learningMaterialStatuses: function(){
    var self = this;
    return DS.PromiseArray.create({
      promise: self.store.find('learning-material-status')
    });
  }.property(),
  learningMaterialUserRoles: function(){
    var self = this;
    return DS.PromiseArray.create({
      promise: self.store.find('learning-material-user-role')
    });
  }.property(),
  actions: {
    addNewLearningMaterial: function(type){
      var self = this;
      if(type === 'file' || type === 'citation' || type === 'link'){
        this.get('learningMaterialStatuses').then(function(statuses){
          self.get('learningMaterialUserRoles').then(function(roles){
            var lm = self.store.createRecord('learning-material', {
              type: type,
              owningUser: self.get('currentUser.content'),
              status: statuses.get('firstObject'),
              userRole: roles.get('firstObject'),
            });
            self.get('newLearningMaterials').addObject(lm);
          });<commit_msg>Make Final the default status for learning materials if it is available<commit_after>import Ember from 'ember';
import DS from 'ember-data';
export default Ember.Component.extend(Ember.I18n.TranslateableProperties, {
  subject: null,
  isCourse: false,
  isSession: Ember.computed.not('isCourse'),
  materials: Ember.computed.alias('subject.learningMaterials'),
  newLearningMaterials: [],
  classNames: ['detail-learning-materials'],
  newButtonTitleTranslation: 'general.add',
  learningMaterialStatuses: function(){
    var self = this;
    return DS.PromiseArray.create({
      promise: self.store.find('learning-material-status')
    });
  }.property(),
  learningMaterialUserRoles: function(){
    var self = this;
    return DS.PromiseArray.create({
      promise: self.store.find('learning-material-user-role')
    });
  }.property(),
  actions: {
    addNewLearningMaterial: function(type){
      var self = this;
      if(type === 'file' || type === 'citation' || type === 'link'){
        this.get('learningMaterialStatuses').then(function(statuses){
          self.get('learningMaterialUserRoles').then(function(roles){
            //default the status to Final if that status exists
            var defaultStatus = statuses.find(function(status){
              return status.get('title') === 'Final';
            });
            if(!defaultStatus){
              defaultStatus = statuses.get('firstObject');
            }
            var lm = self.store.createRecord('learning-material', {
              type: type,
              owningUser: self.get('currentUser.content'),
              status: defaultStatus,
              userRole: roles.get('firstObject'),
            });
            self.get('newLearningMaterials').addObject(lm);
          });
{'fraction_non_alphanumeric': 0.13989311537252436, 'fraction_numerical': 0.0012574662055957245, 'mean_word_length': 3.1164294954721865, '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': '4031501', 'n_tokens_mistral': 891, 'n_tokens_neox': 862, 'n_words': 169}