<commit_before>import Ember from 'ember';
import DS from 'ember-data';

const { computed, inject, RSVP, ObjectProxy, Component } = Ember;
const { service } = inject;
const { PromiseObject } = DS;
const { collect, sort } = computed;

const CourseProxy = ObjectProxy.extend({
  content: null,
  currentUser: null,
  showRemoveConfirmation: false,
  status: computed('content.isPublished', 'content.isScheduled', function(){
    let course = this.get('content');
    if (course.get('isScheduled')) {
      return 's';
    }
    if (course.get('isPublished')) {
      return 'p';
    }

    return 'd';
  }),
  userCanDelete: computed('content', 'currentUser.model.directedCourses.[]', function(){
    let defer = RSVP.defer();
    const course = this.get('content');
    if (course.get('isPublishedOrScheduled')) {
      defer.resolve(false);
    } else {
      this.get('currentUser.userIsDeveloper').then(isDeveloper => {
        if(isDeveloper){
          defer.resolve(true);
        } else {
          this.get('currentUser.model').then(user => {
            user.get('directedCourses').then(directedCourses => {
              defer.resolve(directedCourses.contains(course));
            });
          });
        }
      });
    }

    return PromiseObject.create({
      promise: defer.promise
    });
  })
});
export default Component.extend({
  currentUser: service(),
  courses: [],
  proxiedCourses: computed('courses.[]', function(){
    return this.get('courses').map(course => {
      return CourseProxy.create({
        content: course,
        currentUser: this.get('currentUser')
      });
    });
  }),
  sortBy: 'title',
  sortCourseBy: collect('sortBy'),<commit_msg>Use translations instead of English keys for sorting courses<commit_after>import Ember from 'ember';
import DS from 'ember-data';

const { computed, inject, RSVP, ObjectProxy, Component } = Ember;
const { service } = inject;
const { PromiseObject } = DS;
const { collect, sort } = computed;

const CourseProxy = ObjectProxy.extend({
  content: null,
  currentUser: null,
  showRemoveConfirmation: false,
  i18n: null,
  status: computed('content.isPublished', 'content.isScheduled', function(){
    const i18n = this.get('i18n');
    let course = this.get('content');
    let translation = 'general.';
    if (course.get('isScheduled')) {
      translation += 'scheduled';
    } else if (course.get('isPublished')) {
      translation += 'published';
    } else {
      translation += 'notPublished';

    }

    return i18n.t(translation).string;
  }),
  userCanDelete: computed('content', 'currentUser.model.directedCourses.[]', function(){
    let defer = RSVP.defer();
    const course = this.get('content');
    if (course.get('isPublishedOrScheduled')) {
      defer.resolve(false);
    } else {
      this.get('currentUser.userIsDeveloper').then(isDeveloper => {
        if(isDeveloper){
          defer.resolve(true);
        } else {
          this.get('currentUser.model').then(user => {
            user.get('directedCourses').then(directedCourses => {
              defer.resolve(directedCourses.contains(course));
            });
          });
        }
      });
    }

    return PromiseObject.create({
      promise: defer.promise
    });
  })
});
export default Component.extend({
  currentUser: service(),
  i18n: service(),
  courses: [],
  proxiedCourses: computed('courses.[]', function(){
    const i18n = this.get('i18n');
    return this.get('courses').map(course => {
      return CourseProxy.create({
        content: course,
        i18n,
        currentUser: this.get('currentUser')
      });
    });
  }),
  sortBy: 'title',
  sortCourseBy: collect('sortBy'),
{'fraction_non_alphanumeric': 0.15608825932988288, 'fraction_numerical': 0.004358485426314356, 'mean_word_length': 3.021905805038335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3204705', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1075, 'n_words': 219}